The DropDownList drop down box selects the of recommendation to change the trigger event and prevent global refresh

  • 2021-08-21 20:05:39
  • OfStack

Code:


<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
//ASP.NET Use in UpdatePanel Implement local asynchronous refresh 
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:DropDownList runat="server" ID="SelectProductType" AutoPostBack="True" OnSelectedIndexChanged="SelectProductTypeChange" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="SelectProductType" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
// Background drop-down box selects change trigger event 
protected void SelectProductTypeChange(object sender, EventArgs e)
{
//
}

asp: ScriptManager Overview:

1. ScriptManager (script controller) is the foundation of asp. net ajax.

2. Only one ScriptManager per page is allowed and placed in front of other ajax controls.

3. ScriptManager is in charge of many scripts of the client Ajax page, and registers Ajax class library in the page to realize local update of the page and call Web service.

Reference and: Simple usage of ScriptManager

Note:

1. The combination of ScriptManager and UpdatePanel controls can achieve the effect of asynchronous local update of pages. UpdatePanel is the asynchronous local update area in the setup page, which must depend on the existence of ScriptManager, because ScriptManger control provides the function of client script generation and management of UpdatePanel.

2. There is an button outside updatepanel. If you set it to AsyncPostBackTrigger, the button page will not refresh


Related articles: