ASP. NET Ajax in-depth introduction series (2): Use of updatepanel (I) Notes

Source: Internet
Author: User

1. Use the methods supported by the Framework to register scripts,

(1) registerarraydeclaration outputs the array definition to the page
(2) registerclientscriptblock output script (followed by this from)
(3) registerclientscriptinclude Add a reference to the script
(4) registerclientscriptresource Obtains resources from the Assembly
(5) add additional properties to the control using registerexpandoattribute
(6) Add a hidden control to registerhiddenfield
(7) registeronsubmitstatement can be used to add a statement and return a value. If it is true, it will be successfully submitted next time.
(8) registerstartupscript outputs the script to the page (followed by/from)

You can use the method below scriptmanage to replace

2. updatepanel attribute 1: rendermode is divided into two values: block contains content with Div, inline contains content with span

3. updatemode attribute: it is also divided into two values: always, all actions are refreshed, and conditional is refreshed only by the internally active control.

4. childrenastriggers: whether to send asynchronous requests. If it is set to false, setting updatemode to always will cause an exception.

5. triggers setting controls that trigger updatepanel

6. scriptmanager. getcurrent (this). registerasyncpostbackcontrol (this. button1 );
Scriptmanager. getcurrent (this). registerpostbackcontrol (this. button2 );
Set trigger in code
Protected void button#click (Object sender, eventargs E)
{
This. updatepanel1.update ();
}

7. In updateprogress, you can set associatedupdatepanelid to specify the updatepan to be triggered, displayafter to set the delay time, And dynamiclayout to specify whether to occupy a space during hiding.

Error Handling: Server
8. allowcustomerrorsredirect attribute in scriptmanager: whether to redirect due to an error in Web. config

9. asyncpostbackerror event: the event triggered when an error occurs during asynchronous refresh.

1 protected void scriptmanagerpolicasyncpostbackerror (Object sender, asyncpostbackerroreventargs E)
2 {
3 scriptmanager. getcurrent (this). asyncpostbackerrormessage = E. Exception. message;
4}

10. asyncpostbackerrormessage attribute: error message received by the client

Client:
Responds to the endrequest event of pagerequestmanager.

Set the errorhandled attribute to true.

1 SYS. webforms. pagerequestmanager. getinstance (). add_endrequest (function (sender, E)
2 {
3 E. set_errorhandled (true );
4 $ get ("error"). innerhtml = "sorry, an error has occurred:" + E. get_error (). message;
5 setTimeout (function () {$ get ("error"). innerhtml = "" ;}, 3000 );
6 });

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.