Stuart Evans

This week I will be mostly using............

  Home  |   Contact  |   Syndication    |   Login
  4 Posts | 0 Stories | 20 Comments | 12 Trackbacks

News

Archives

Post Categories

BizTalk 2004

Solution Providers

Monday, May 14, 2007 #

My customer has a requiirement for simple wizard style (ie Next>>Next) navigation

Typical Example would be to enter details for a purchase order header, then to press "Next" and the user is taken immediately to the window for adding lines.

Investigation

I found number of ways to manipulate the navigation options of a SharePoint edit form page these being:

1) You can add a source querystring parameter to the url of the first page. This allows you to enter details for the header and then get routed to the child page that you specify in the source querystring variable as per this post.

2. You can open you NewForm.aspx , HIDE the standard list form DONT DELETE IT  (refer to http://blogs.msdn.com/dszabo/archive/2007/02/20/custom-list-newform-aspx-ruined-in-wss-3-0.aspx for details why)  insert a custom list form and remove the sharepoint:savebutton controls and replace them with form action controls. The form action controls have a number of options - these being documented here . However in my example I wanted to append the url of the redirect with a querystring property and after loads of investigation of trying to customise the navigate to page option of the form action control I gave up (the JavaScript code generates a postback to the server which controls the redirect process. The catch is that the JavaScript is generated using xslt and it beat me. Challenge anyone to get it working!)

3. You could replace the sharepoint:savebutton with a standard asp.net button and wire it up to some inline inline C#. As mentioned in my example I wanted to save the data entered and add a runtime querystring parameter to the end of the url.

So. to achieve a simpl save and redirect you can implement the following :

1. Add your inline C# code to your SharePoint page (i.e.)

<script type="text/c#" runat="server">
    void SaveAndRedirect(object sender, System.EventArgs e)
    {

//Implement your own code for creating the url
  string redirectUrl ="http://vsmoss?paramName=12345";
  SPContext.GetContext(this.Context).Item.Update();
  Response.Redirect(redirectUrl  );
    }
</script>

2. Add PageParserPath entry to your web.config. You will need to modify the virtual path to reflect the name and url of your custom page.

<PageParserPaths>  
<PageParserPath VirtualPath="/Services/Lists/Calendar/*" CompilationMode="Always" AllowServerSideScript="true" IncludeSubFolders="true" />
</PageParserPaths>

3. Add your asp.net button to your page.

 <asp:Button runat="server" Text="Button" id="Button1" OnClick="SaveAndRedirect"/>

You will need to restart IIS for the changes to take effect.

This technique is an extension to a post from Nick Swan who discusses inlining C# in master pages but isn’t too keen on thee idea. I'm open to suggestions as to whether standard aspx pages are candidates for this type of modification.

Conclusion

If you need simple navigation logic then this technique works. Of course there is more than likely a slicker solution that I haven’t thought of . I guess the most likely solution would be to create a SharePoint form control that inherits from one if the controls in the Microsoft.Sharepoint.WebControls namespace. I attempted this and managed to get it rendering in SPD but kept getting runtime errors that I couldn’t get to the bottom of. If anyone has implemented a custom SharePoint form button I'd love to find out how they got it working.