我正在尝试变得圆滑,并且将此用户控件放在覆盖整个页面的 div 中。但是,当我单击搜索按钮时,我会收到完整的回发。关于如何让它不回发并只更新gridview的任何想法?
只是要清楚。以下控件位于 ascx 文件中。在 aspx 页面中调用。
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="PropertyViewAddEntity.ascx.cs"
Inherits="UserControls_PropertyViewAddEntity" %>
<p>Search for State City County zip</p>
<asp:Panel ID="Panel1" runat="server" DefaultButton="Button2ae">
<p>
<asp:TextBox ID="TextBox1ae" runat="server" Width="500px"></asp:TextBox>
<asp:Button ID="Button2ae" runat="server" Text="Search" CausesValidation="false" />
</p>
</asp:Panel>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:GridView ID="GridView2ae" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource3ae"
OnSelectedIndexChanged="GridView2ae_SelectedIndexChanged">
<Columns>
<asp:CommandField ShowSelectButton="True" />
<asp:BoundField DataField="zipcodeid" HeaderText="zipcodeid" SortExpression="zipcodeid" />
<asp:BoundField DataField="zip_code" HeaderText="zip_code" SortExpression="zip_code" />
<asp:BoundField DataField="state" HeaderText="state" SortExpression="state" />
<asp:BoundField DataField="city_alias_name" HeaderText="city_alias_name" SortExpression="city_alias_name" />
<asp:BoundField DataField="county_name" HeaderText="county_name" SortExpression="county_name" />
</Columns>
</asp:GridView>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button2ae" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
顺便说一句,控件位于占位符中
<asp:PlaceHolder ID="ControlContainer" runat="server"/>
并从后面的代码中调用。
Control mycontrol = LoadControl("~/UserControls/PropertyViewAddEntity.ascx");
ControlContainer.Controls.Add(mycontrol);