If for instance, I was to give a response back to an ASP.Ne开发者_如何学JAVAt Update Panel page, but use Response.Write and then end it before anything was rendered, what is the minimum I would need to write in the Response.Write?
If you take the following UpdatePanel ...
<asp:UpdatePanel runat="server" id="updatePanel" ChildrenAsTriggers="True">
<ContentTemplate>
<asp:TextBox runat="server" ID ="textbox1"/>
<asp:Button runat="server" ID="go" OnClick="OnGo" text="Go"/>
</ContentTemplate>
</asp:UpdatePanel>
... then click the button and view the response in Firebug, you'll get something like this (I've truncated the viewstate and event validation to make it a bit more readable):
265|updatePanel|updatePanel|
<input type="text" name="textbox1" value="content" id="input1" />
<input type="submit" name="go" value="Go" id="go" />|
52|hiddenField|__VIEWSTATE|/wXPZwUK...|
64|hiddenField|__EVENTVALIDATION|/wEWB...|
0|asyncPostBackControlIDs|||0|postBackControlIDs|||
12|updatePanelIDs||tupdatePanel|0|childUpdatePanelIDs|||
11|panelsToRefreshIDs||updatePanel|2|asyncPostBackTimeout||90|20|
formAction||Upagename.aspx|13|pageTitle||Untitled Page|
All that extra data is stuff that the ScriptManager
needs to rebuild the contents of the UpdatePanel: control ids, the page name, viewstate, etc.. This is what you'd have to Response.Write
manually for the ScriptManager
to be able to do its job.
For details, see "ScriptManager Enables AJAX In Your Web Apps". At the end of the section titled "Putting the AJAX in ASP.NET AJAX", the author explains what's going on:
Finally, the client framework gets the asynchronous response from the server and parses out data. The ScriptManager control has packed into the response all the control IDs and new markup so the client framework can simply perform scripting operations on the browser's document object model to update the page content.
精彩评论