Tips and tricks: support the back/forward button in ASP. NET Ajax updatepanel

Source: Internet
Author: User

[Original address] tip/TRICK: Enabling back/forward-button support for ASP. NET Ajax updatepanel
[Original article publication date] Thursday, September 14,200 6

Nikhil recently wrote a good post about a new ASP. Net Control called historycontrol that supports Ajax. After it is added to the page, developers can use programming methods to add a logical view to the browser's historical records ). This will make Ajax-enabled websites more useful and follow the standard forward/backward navigation practices of traditional Web applications.

For example, with historycontrol of Nikhil, developers can write an encoding similar to the following to respond to a list selection change and add the list selection as an identifier to the browser's historical records:

Private void contentlist_selectedindexchanged (Object sender, eventargs e ){
History. addentry (contentlist. selectedindex. tostring ();
}

 

Once you add a new item to the history control, the back/forward button in the browser is activated. The history control of Nikhil provides a navigate event. When you press the back/forward button in the browser, this event will be triggered, at the same time, it provides the identifier used to add the logic View to the browser's historical records in the event processing function parameters. Then you can use this identifier to restore the page to the page status corresponding to this historical record:

 

Private void historycontrol_navigate (Object sender, historyeventargs e ){

Int selectedindex = 0;

If (string. isnullorempty (E. identifier) = false ){
Selectedindex = int32.parse (E. identifier );
}

// Update the content being displayed in the page
Contentlist. selectedindex = selectedindex;

// Mark the update panels as needing an update
Mainupdatepanel. Update ();
}

 

In this way, you can also use the forward/backward button for navigation when using Ajax applications. You can download the code of the Nikhil history control here and use it in your project.

I hope this article will help you,

Scott

Tags: ASP. NET,. net, Atlas, tips and tricks

(Translated by Si GUI)

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.