简体   繁体   English

回发后不会填充asp.net文本框

[英]asp.net textbox doesn't populate after postback

I am using ASP.NET and C# couple text boxes to calculate results entered. 我正在使用ASP.NET和C#对文本框来计算输入的结果。 Textbox2 has a value entered and on button click Textbox1 gets populated. Textbox2输入了一个值,然后单击按钮,填充Textbox1。 This works fine the first time I enter the value. 第一次输入值时,此方法效果很好。 But the second time I change the value in Textbox2, I see that the value is being assigned to Textbox1 while debugging on Button click, but doesn't show up on the screen. 但是第二次更改Textbox2中的值时,我看到在单击Button时进行调试时,该值已分配给Textbox1,但未在屏幕上显示。 I have many other controls and a master page. 我还有许多其他控件和一个母版页。 The textboxes are within an update panel. 文本框在更新面板中。

Can someone help me what's going on? 有人可以帮我怎么回事吗?

Here is the code: 这是代码:

<asp:TextBox ID="Textbox1" runat="server" Width="150px"   TabIndex="6" MaxLength="8"></asp:TextBox>                                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" ControlToValidate="TextBox1" ErrorMessage="*"></asp:RequiredFieldValidator>

<asp:TextBox runat="server" ID="Textbox2" Width="150px" Visible="false"></asp:TextBox>&nbsp

<asp:ImageButton runat="server" ID="imgCalcAdjRate" ImageUrl="~/Resource/Images/calrate_0.bmp" onmouseout="this.src='../Resource/Images/calrate_0.bmp'" onmouseover="this.src='../Resource/Images/calrate_1.bmp'"                    Height="25px" Width="25px" Visible="false" onclick="imgCalcAdjRate_Click" /> 

Check the postback in the page_load function. 在page_load函数中检查回发。

if(!Page.IsPostBack) {

}

I think you are loosing information on post back. 我认为您正在丢失回发信息。 The data is changed, but it get reset on post back. 数据已更改,但会在回发时重置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM