This blog briefly introduces two plug-ins of vs Ajax.
Scripmanager and updatepanel
These two controls are one of the largest ones used in vs sap.net. They are mainly used for partial update of webpage content.
The following is a partial explanation.
Scripmanager
1. It is the script controller, the foundation of the existence of Asp.net. Ajax, and the foundation of all Ajax controls.
2. Only one scriptmanager is allowed for one page and placed in front of other Ajax controls.
3. scriptmanager manages multiple scripts on the client Ajax page and registers the Ajax class library on the page to implement partial page updates and web service calls.
Its basic attributes include the following:
Allowcustomerror: whether to use error handling
Asyncpostbackerrormessage: whether to return an error when an error is returned asynchronously.
Asypostbacktimeout: asynchronous return event display: 90 seconds by default
Enablepartialzrendering: whether partial page refresh is supported
Scriptmode: Specifies the Script Mode sent to the client: There are four types:
Auto, inherit, debug, and release. The default value is aurto.
Scrippath: Set the root directory of all scripts as a global attribute.
Updatepanel Control
Is also one of the most commonly used controls in Ajax, uThe pdatepanel control is used to locally update content on the webpage. The content to be partially updated on the webpage must be
Put inUpdatepanel control. It must be used together with the scriptmanager control mentioned above. Let's take a look at some attributes.
Attribute |
Description |
Children as triggers |
When the updatemode attribute is conditional, whether the asynchronous return of the child control in updatepanel triggers updatepanle update. |
Rendermode |
Indicates the final HTML element of updatepanel. Block (default) indicates <div>, inline indicates <span>
|
Updatemode |
Updatepanel update mode. There are two options: Always and conditional. Always: No matter whether there is a trigger, other controls will update the updatepanel. Conditional indicates that only the trigger of the current updatepanel is available, Or, if the childrenastriggers attribute is true, the asynchronous or whole-page delivery triggered by the control in the current updatepanel is returned, or The updatepanel is updated only when the server calls the update () method. |
Contente Template |
Used to define updatepanel content
|
Triggers |
Asyncpostbacktrigger and postbacktrigger
|
After the basic attributes are described above, we will solve a small problem.
========================================================== ====================================
These are all used to pave the way for this problem.
The problem is that the webpage has a function to delete news.
When we delete news, we refresh the real page. This is what we don't want. Refresh brings unnecessary time and resources. What can we do directly?
Are you sure you want to delete it without refreshing it?
The aso.net. Ajax control we mentioned above is used.
Use Basic control scriptmanager and partial refresh control updatepanel
How is the code written.
First, you must understand that the content should be put in the content of updatepanel.
The content is different. Different templates are required.
Using table data
So the updatepanel contenttemplate attribute is used here.
Place the table data under contenttemplate.
This will solve a small problem.
The instance code is as follows:
<Div class = "fontcolor"> tip: Click the news title to delete the news comment! </Div> <asp: scriptmanager id = "scriptmanager1" runat = "server"> </ASP: scriptmanager> <asp: updatepanel id = "updatepanel1" runat = "server"> <contenttemplate> <Table class = "m_table"> <tr> <TH class = "xuhao"> NO. </Th> <th> title </Th> <TH class = "Del"> modify </Th> <TH class = "Del"> Delete </Th> </tr> <asp: repeater id = "repnews" runat = "server"> <itemtemplate> <tr> <TD> <% # eval ("ID ") %> </TD> <a href = '.. /newscontent. aspx? Newsid = <% # eval ("ID") %> 'target = "_ blank"> <% # eval ("title ") %> </a> </TD> <a href = "#"> modify </a> </TD> <asp: linkbutton id = "lbtndel" onclientclick = "returnconfirm ('delete news will delete comments together, whether to delete ') "onclick =" lbtndel_click "commandargument = '<% # eval (" ID ") %> 'runat =" server "> Delete </ASP: linkbutton> </TD> </tr> </itemtemplate> </ASP: repeater> </table> </contenttemplate> </ASP: updatepanel>
The basic properties of the control are finished, but the instance is not described yet.