Http://blog.csdn.net/huangkelong/article/details/2013466
ASP. net Ajax has a very magical and useful control updatepanel, which can help us easily achieve the non-synchronous PostBack function, let's. ajax technology can be directly added to the ASPX page.
Some readers often ask the author a question: Can I dynamically update the "control" outside updatepanel "in the events triggered in updatepabel?
Generally, when using updatepanel, you can set it as follows:
We usually put the "dynamic update in non-synchronous mode" Control in updatepanel. To update textbox1 in the screen, you only need to writeCode:
Protected sub button#click (byval sender as object, byval e as system. eventargs)
Me. textbox1.text = "..."
End sub
The click event triggered by button1 in updatepanel is executed in non-synchronous PostBack mode. Therefore, when the backend event click is executed, the value in textbox1 can be updated, the page does not need to be changed (submit ).
However, if you have used updatepanel for a long time, you will find that we cannot put all the controls in updatepanel. If you need to dynamically update the content of controls other than updatepanel in non-synchronous PostBack, what should we do? For example:
To update the content of the Control located outside updatepanel after clicking the button in updatepanel, use the tips of dynamic render javascript:
Protected sub button#click (byval sender as object, byval e as system. eventargs)
Dim JS as string
JS = "$ get ('textbox1'). value = '...';"
Scriptmanager. registerstartupscript (Me, GetType (string), "", JS, true)
End sub
In this way, you can use the dynamically generated JavaScript to update the controls that are placed outside the updatepanel on the front-end page.
In fact, this tip is quite useful. We can also use it to dynamically generate an alert window in the non-synchronous PostBack process. For example:
Protected sub button#click (byval sender as object, byval e as system. eventargs)
Dim JS as string
JS = "alert ('alert window generated during non-synchronous PostBack ...');"
Scriptmanager. registerstartupscript (Me, GetType (string), "", JS, true)
End sub
I hope this tips will help you with Ajax technology...
Trackback: http://tb.blog.csdn.net/TrackBack.aspx? Postid = 1870893