Showing the user a custom page after list add in Sharepoint 2007 - sharepoint-2007

After my user adds a new list item with my custom list page, Sharepoint 2007 redirects them to AllItems.aspx. I want them to go the the custom page ThankYou.aspx instead.
My buttos are the standard buttons generated by SharePoint Designer
<table>
<tr>
<td width="99%" class="ms-toolbar" nowrap=""><IMG SRC="/_layouts/images/blank.gif" width="1" height="18"/></td>
<td class="ms-toolbar" nowrap="">
<SharePoint:SaveButton runat="server" ControlMode="New" id="savebutton2"/>
</td>
<td class="ms-separator"> </td>
<td class="ms-toolbar" nowrap="" align="right">
<SharePoint:GoBackButton runat="server" ControlMode="New" id="gobackbutton2"/>
</td>
</tr>
</table>
I have seen several solutions that require adding 150 lines of JavaScript or changing the underlying SharePoint code, and I just can't believe that is the solution - I think either it is so simple that no one has written about it, or I am using the wrong search term to look for it.

I was just overlooking something simple.
The Source parameter on the form link will change the redirect for you. So if your custom form is at
https://myserver/lists/customadd.aspx
Then you can just add the source parameter and Sharepoint will redirect there on submit:
https://myserver/lists/customadd.aspx?Source=ThankYou.aspx

Related

Submit cell data from table in thymeleaf template

I have following code snippet:
<table class="table">
<thead>
<tr>
<th>Type</th>
<th>Title</th>
</tr>
</thead>
<tbody>
<tr th:if="${list.isEmpty()}">
<td colspan="2">No Media Available</td>
</tr>
<tr th:each="media : ${list}">
<form th:action="#{/pages}" method="post">
<td><span th:text="${media.getType()}">Type</span></td>
<td><span th:text="${media.getTitle()}">Title</span></td>
<td><input name="submit" type="submit" value="add"/></td>
</form>
</tr>
</tbody>
Now to my question: How can I submit the content from the rows?
Another question: Is my approach to creating a form for each row makes sense at all?
If you want to have user-entered data sent to the server, then replace this:
<td><span th:text="${media.getTitle()}">Title</span></td>
with this:
<td><input name="title" th:value="${media.title}"></td>
Assuming the ${media.title} evaluates to "War and Peace" This will use the name field to submit data as title=War and Peace (with URL encoding for the spaces in the title: War%20and%20Peace).
Note the use of ${media.title} instead of ${media.getTitle()}. You should be able to refer to the field name, rather than the get method. Thymeleaf will use the getFoo() method for a field called foo, based on naming conventions.
There are other approaches, for example:
use a visible input field, but styled to look and behave like regular text (cannot be edited, and has no surrounding box).
use JavaScript to replace the default form submission process, and read your row data from the vanilla table, without a form - instead, with a button using a click event handler.
If you create one form for the entire table, you're going to get all the table's data submitted at once (arrays of title data, and so on).
Alternatively, if you have one form per table row, you have to consider what happens if a user edits multiple rows of data before hitting submit for one row. All those other unsent changes will potentially be lost.
A common solution is to avoid this problem, by forcing users to update records one at a time: The table does not use forms. Each row's button click opens a new modal dialog containing the data for only that one row (in a form) - which can then be edited and submitted.

Ordering Members in Umbraco 7 Back Office

We are currently utilising the Umbraco 7 membership service. Our site creates members as part of a sign-up process.
In the CMS side of Umbraco I can see that the members should be sorted into folders alphabetically, however it would appear that the Name is being used to sort. This causes issues as the Name is for example "Mr Joe Blogs" which means nearly everyone ends up in the "M" folder. We have custom properties for title, forename and surname on the member object.
How can I configure umbraco to sort in to alphabetical folders by the surname property.
Also on the members manage tab Name is displayed on the grid how can I change this to surname and forename?
Update:
So i've done a bit more investigation and I can see that I have the MemberListView for Umbraco 7 installed and I file called memberListView.html which has an angularjs bound template and the bit I am looking at is:
<tr ng-repeat="result in listViewResultSet.items"
ng-class="{selected:result.selected}">
<td>
<i class="icon {{result.icon}}" ng-class="getIcon(result)"></i>
<input type="checkbox" ng-model="result.selected">
</td>
<td>
<!-- ng-class="{inactive: entityType === 'content' && !result.published}" - use this as a template to color based on locked/approved state -->
<a href="#" ng-click="editMember(result.key)" prevent-default>{{result.name}}</a>
</td>
<td>
{{result.email}}
</td>
<td colspan="2">
<span title="{{getLockedDescription(result)}}" ng-class="getLockedIcon(result)"></span>
<span title="{{getSuspendedDescription(result)}}" ng-class="getSuspendedIcon(result)"></span>
</td>
</tr>
When I try and get my custom property off result it isn't there but looking at the JSON some standard properties are there.
If you modify the List View - Members data type in the Developer section you can select the property that you would like to order the members by. It also gives you the option to change which columns appear in the grid so you should be able to replace the Name property with Forename and Surname.
If you've managed to organise the members into alphabetical folders then you may have performed some customisation already. As far as I know this isn't possible out of the box.

How to open a view form server site and display its link in Asp.net MVC?

I wrote a Web Application. In which the users can make inputs which will be saved
in a database. (with a [HttpPost] function). From these functions I open other Views. My problm is that althought the Views show up without any problem the path in the link stays the same. This is problematic when I want to go back or I want to copy the link... My idea was to somehow display the link per javascript everytime I load a View but that seems to be a very unprofessional way of doing it.
Simple,
<div class="table-outer">
<table width="50%" align="center" border="1">
<tr>
<td>Column1</td>
<td>Column2</td>
<td>Column3</td>
<td>Column4</td>
</tr>
</table>
</div>
.table-outer{width:100%; background:#ddd;padding:20px}
automatically align center
https://jsfiddle.net/kamatchikumar/3u5qwqms/

Clicking on image using RSpec & Capybara

I'm using Rspec and Capybara.
I am attempting to click an image, but cannot find a way to get Capybara to click the image. I'm not sure what to do, as I have in fact same class, alt and src.
Thanks
Example of html
<tr class="even">
<td class="gridData" style="text-align:center;">
<td class="gridData"> 221 </td>
<td class="gridData" route="default" reset="0" urlparams="users index edit {userID}" label="Username">
<td class="gridData">
<img class="user-info-grid" alt="info" src="/themes/system/images/icon/16/information.png">
</td>
</tr>
<tr class="odd">
<td class="gridData" style="text-align:center;">
<td class="gridData"> 222 </td>
<td class="gridData" route="default" reset="0" urlparams="users index edit {userID}" label="Username">
<td class="gridData">
<img class="user-info-grid" alt="info" src="/themes/system/images/icon/16/information.png">
In fact here is the source, which I want to test:
<img class="user-info-grid" alt="info" src="/themes/system/images/icon/16/information.png">
But as I said, I cannot find a way to get Capybara to click the image.
Any ideas?
You can use this:
page.first(".user-info-grid").click
This is use to find user-info-grid class and apply click function.
If multiple classes are comes with this name then the click will execute in first found class.
You can use that when looking for an id:
find("#the_id").click
Or for a class
find(".the_class").click
I put this and works:
find("img[src*='myphoto.jpg']").click
That's because your image is an image, not a link. Wrap it inside a link first, then click the link, like so:
<img ... />
Do I understand correctly that there's no <a> element because you're using a JavaScript onclick handler? If so, then you need to be aware that plain Capybara doesn't do JavaScript. You need to use capybara-webkit, Selenium, or something else similar.
But I'd advise you to put in the <a> element, and apply the JS handler to that. That will make it easier for user agents without JavaScript to handle (yes, there still are some!).
And Matthias is right: make your HTML valid.
Try using XPath, if not that then you can use either visit_to the source of the link, or you can use try help on http://railscasts.com/episodes/257-request-specs-and-capybara

ASP.NET MVC Html.TextBox won't compile at runtime - same files work in other projects

We have two separate front end projects for the same company which are basically the same except for all the html and css. (Different divisions within the same company) I'm trying to add a page that was built in one over to the other. (Yes, yes, I know we probably should've built a single app that display different presentations based on which division's instance was running so that we wouldn't have to maintain two separate but the same codebases, but we just can't go there with this client.)
Anyway, I copied over the controller, the model, and the aspx and ascx pages. All I needed to change was the name on the root namespace. For some reason, a particular ascx page that compiles successfully in the first project, fails in the second project.
Here's the error message:
e:\pathtocode\Web\Views\EmailToFriend\Email.ascx(24): error CS1061:
'System.Web.Mvc.HtmlHelper<MainWeb.Models.EmailToFriend>' does not contain a definition for
'TextBox' and no extension method 'TextBox' accepting a first argument of type
'System.Web.Mvc.HtmlHelper<MainWeb.Models.EmailToFriend>'
could be found (are you missing a using directive or an assembly reference?)
Here's the code for the ascx:
<%# Control Language="C#" AutoEventWireup="true" CodeBehind="Form.ascx.cs"
Inherits="MainWeb.Views.EmailToFriend.Form" %>
<%# Import Namespace="System.Web.Mvc" %>
<table>
<span class="error" style="color: red;">
<%= Model.ErrorString %>
</span>
<tr>
<td>Friend's Name: </td>
<td><%= Html.TextBox("RecipientName", Model.RecipientName)%></td>
</tr>
<tr>
<td>Friend's Email Address: </td>
<td><%= Html.TextBox("RecipientAddress", Model.RecipientEmail)%></td>
</tr>
<tr>
<td>Your Name: </td>
<td><%= Html.TextBox("SenderName", Model.SenderName ?? UserName)%></td>
</tr>
<tr>
<td>Your Email Address: </td>
<td><%= Html.TextBox("SenderAddress", Model.SenderEmail ?? UserEmail)%></td>
</tr>
<tr>
<td>Message</td>
<td><%= Html.TextArea("Message", Model.Message) %></td>
</tr>
<tr>
<td colspan="2"><input type="submit" value="Send" style="float: right;"/></td>
</tr>
</table>
I've been futzing around with everything I could think of. Html.TextBox works fine in other files in the same project, so I can't figure out why this is blowing chunks.
UPDATE
I've just discovered that in the project where this code works, VS recognizes the project as an MVC web application, but in the second one where it doesn't work, VS does not recognize that it's MVC. At least if I right click on a Views subfolder the former has a context menu item for 'New View', where the latter project doesn't have this.
Now all I have to do is figure out how to turn it into an MVC project, and maybe that will fix it.
UPDATE #2
Drat, that didn't work. I modified the Import directive to use System.Web.Mvc.Html, and now at least intellisense shows the definition for the .TextBox extension - will try restarting the box to see what happens. :(
final update
As I posted in the comments, I found the error and it had to do with a completely different file, so it was basically my mistake and not a code problem. :(
Are you sure Form (as in Inherits="MainWeb.Views.EmailToFriend.Form") inherits from MVC's ViewPage base class?
My guess is you either want to have
Inherits="System.Web.Mvc.ViewPage"
or
namespace MainWeb.Views.EmailToFriend
{
public class Form : System.Web.Mvc.ViewPage
{
}
}
Most likely you also don't need CodeBehind="Form.ascx.cs". Did you add a regular web form instead of MVC view to your project?
Have you made sure that the compiler is set to 3.5 in the codedom section of the web.config? I battled for hours trying to figure out why I could not use html helpers, most posts are advising to add the System.Web.Mvc.Html namespace which is neccessary for the intellisense, yet since the pages aren't compiled until they are rendered you don't realise that this is false security. Here is a post to fix the compiler version issue: Problem creating my own extension to HtmlHelper

Resources