本文介绍了如何在 asp 中使用更新面板更新文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
限时送ChatGPT账号..我在 UpdatePanel
外面有一个 TextBox
,在 Updatepanel
里面有一个 Button
当我点击 Button
它在 TextBox
中显示值.
I Have a TextBox
outside the UpdatePanel
and a Button
inside the Updatepanel
When i click on the Button
it show value in TextBox
.
我编写了以下代码.
<%@ Register TagPrefix="AjaxToolKit" Assembly="AjaxControlToolkit"
Namespace="AjaxControlToolkit" %>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server"
EnablePageMethods="true" />
<asp:TextBox ID="TextBox5" runat="server" />
<asp:UpdatePanel runat="server" ID="Up1">
<ContentTemplate>
<asp:Button ID="btn" runat="server" onclick="btn_Click" />
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
----------代码隐藏---------
----------Code Behind---------
protected void btn_Click(object sender, EventArgs e)
{
TextBox5.Text = "20000";
}
推荐答案
除非您将文本框值放入更新面板,否则无法更新它.
Your textbox value can't be updated untill you put it in an update panel.
<ContentTemplate>
<asp:TextBox ID="TextBox5" runat="server" />
<asp:Button ID="btn" runat="server" onclick="btn_Click" />
</ContentTemplate>
或者,如果您注册按钮的触发器并从更新中拉出按钮会更好,例如...
OR, it would be better if you register a trigger of the button and pull your button out from your update, like...
<asp:UpdatePanel runat="server" ID="upnl" UpdateMode="Conditional" >
<ContentTemplate>
<asp:TextBox ID="TextBox5" runat="server" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btn" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
这篇关于如何在 asp 中使用更新面板更新文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论