网站上的三个部份都是用自定义控件实现的:Header,Container,Footer;均放在UpdatePanel里,整个网站都使用异步回传机制.
Header里有一个搜索框:<div id="search">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<input id="query" size="40" maxlength="2048" value="" type="text" runat="server" />
<asp:Button ID="SearchButton" runat="server" Text="Search" onclick="Search_Click" />
</ContentTemplate>
</asp:UpdatePanel>
</div>Container里有多个自定义控件,其中一个如下:<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<ul:textShow ID="Show1" runat="server" /> ///主要用于显示一些基本信息
</ContentTemplate>
</asp:UpdatePanel>如何实现点击Header里的搜索,在Container里异步更新搜索出来的信息? 弄蛮久了未解决,请大侠们帮帮忙!
Header里有一个搜索框:<div id="search">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<input id="query" size="40" maxlength="2048" value="" type="text" runat="server" />
<asp:Button ID="SearchButton" runat="server" Text="Search" onclick="Search_Click" />
</ContentTemplate>
</asp:UpdatePanel>
</div>Container里有多个自定义控件,其中一个如下:<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<ul:textShow ID="Show1" runat="server" /> ///主要用于显示一些基本信息
</ContentTemplate>
</asp:UpdatePanel>如何实现点击Header里的搜索,在Container里异步更新搜索出来的信息? 弄蛮久了未解决,请大侠们帮帮忙!
Hack, Everything!
看看这种办法 参考
就是想通过Header搜索框,在一个自定义控件里异步更新搜索出来的内容!
是的,每个部件里都运用了UpdatePanel
就是说要有一个条件来触动这个panel中的刷新而且这个panel中还有一个 <Triggers>
<asp:AsyncPostBackTrigger ControlID="指定为你的搜索按钮" />
</Triggers>这样你在搜索按钮事件中对你的text1进行数据源绑定并且实现异步
<Triggers>
<asp:AsyncPostBackTrigger ControlID="指定为你的搜索按钮" />
</Triggers>调试出现下面的错误:
未能为 UpdatePanel“WidgetBodyUpdatePanel”中的触发器找到 ID 为“SearchButton”的控件。是不是服务器控件生成客户端ID不同?
protected void Page_Load(object sender, EventArgs e)
{
Button bt = (Button)this.Head1.FindControl("SearchButton"); //Head1是一个自定义控件
bt.Click += new EventHandler(bt_Click);
} void bt_Click(object sender, EventArgs e)
{
TextBox tb = (TextBox)this.Head1.FindControl("UpdatePanel1").FindControl("query");
if (tb.Text.Equals("") || tb.Text.Equals(null))
{
return;
}
else
{
USStock.code = tb.Text;
} UpdatePanel up = (UpdatePanel)this.WidgetTabHost.FindControl("WidgetBodyUpdatePanel");//WidgetTabHost,自定义控件
up.Update(); }