Книга: C# 2008 Programmer
Using Triggers to Cause an Update
Using Triggers to Cause an Update
So far, you have used the <asp:UpdatePanel>
control to enclose controls to ensure that changes in this control do not cause a postback to the server. If you select a publisher from the dropdown list, though, you will realize that the entire page is refreshed. By adding a trigger to the page, you can specify a control (and, optionally, its event) that causes an <asp:UpdatePanel>
control to refresh. The trigger <asp:AsyncPostBackTrigger>
causes an update when the specified control raises an event. In other words, when a control specified by a trigger causes an update to a control located with an <asp:UpdatePanel>
control, only the control is updated and not the entire page.
Here's the markup you need to add a trigger to an <asp:UpdatePanel>
control:
<asp:UpdatePanel runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="DropDownList1"/>
</Triggers>
<ContentTemplate>
...
Here, the <asp:UpdatePanel>
control will refresh whenever the value of DropDownList1
changes.
Press F5 to test the application. Now selecting a publisher from the dropdown list updates the GridView
control without causing a refresh in the page.
- Building Responsive Applications Using AJAX
- AJAX- Enabling a Page Using the ScriptManager Control
- Using the UpdatePanel Control
- Caveats using NAT
- Using Double Quotes to Resolve Variables in Strings with Embedded Spaces
- Data Binding Using the GridView Control
- Using the kill Command to Control Processes
- Installing Using a Network
- Using X
- Using a Display Manager
- Starting X from the Console by Using startx
- Using Fedora's switchdesk Client