More in this section
Blogs RSS feed

Transferring modules built prior to Sitefinity 3.6 to the new backend architecture: Moving away from postbacks

by User Not Found
[This post is part of the developer's manual preview published on this blog. You can find temporary TOC here.]


Once we have separated the ControlPanel modes into Views, we will need to modify the way we used to navigate between the modes into the Views navigation. Let us again start by looking how we would typically change the ControlPanel mode in Sitefinity versions prior to 3.6. We will examine this approach on the built-in Lists module.


For example, in order to create a new list, we would provide our user with a following control:
<asp:LinkButton ID="newListButton" runat="server" cssClass="CmsButLeft new" Text="<%$Resources:CreateNewList %>"></asp:LinkButton> 
Then, in the ControlPanel class we would wire the Command event of this LinkButton as follows:
this.cntAll.NewListButton.CommandName = "NewList"
this.cntAll.NewListButton.Command += new CommandEventHandler(Button_Command); 
And finally, in the Button_Command event handler, we would handle the “NewList” command as follows:
this.Mode = DisplayMode.NewList; 
Which would then start the process of recreating child controls, this time with the Mode property being set to “NewList”? We have outlined numerous times the drawbacks of this approach. Let us know see how would we rewrite this same button for the new backend architecture introduced in Sitefinity 3.6.


First of all, instead of LinkButton we will now have HyperLink since, by clicking on the button we actually wish to go to a different url, not just perform a postback.

<asp:HyperLink ID="newListButton" runat="server" cssClass="CmsButLeft new" Text="<%$Resources:CreateNewList %>"></asp:HyperLink> 
Secondly, we will not wire the control to any events, but will simply set it’s NavigateUrl property as follows:

NewListButton.NavigateUrl = this.CreateHostViewCommand<ListInsert<AllListsView>>(); 
And we are done. We will have to repeat this procedure for all the buttons which purpose used to be to switch the current mode of a given ControlPanel class. 




Leave a comment
  1. Romi Apr 23, 2009
    Ok, But how to perform one action or event handler to this new hyperlink. Sometimes we need to initialize some external methods or values in our modules.
  2. Kevin Jun 26, 2009
    Indeed ... i'm having the same problem.  I actually need to have a postback in my user controls, and I'm not sure any more how to handle it?

    Leave a comment