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

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

Posted on April 21, 2009 0 Comments

The content you're reading is getting on in years
This post is on the older side and its content may be out of date.
Be sure to visit our blogs homepage for our latest news, updates and information.

[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. 

 

 


progress-logo

The Progress Team

View all posts from The Progress Team on the Progress blog. Connect with us about all things application development and deployment, data integration and digital business.

Comments

Comments are disabled in preview mode.
Topics

Sitefinity Training and Certification Now Available.

Let our experts teach you how to use Sitefinity's best-in-class features to deliver compelling digital experiences.

Learn More
Latest Stories
in Your Inbox

Subscribe to get all the news, info and tutorials you need to build better business apps and sites

Loading animation