asp.net 文本框在回发后不会填充 [英] asp.net textbox doesn't populate after postback

查看:29
本文介绍了asp.net 文本框在回发后不会填充的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 ASP.NET 和 C# 组合文本框来计算输入的结果.Textbox2 输入了一个值,单击按钮时 Textbox1 被填充.这在我第一次输入值时工作正常.但是第二次更改 Textbox2 中的值时,我看到该值在调试按钮单击时分配给 Textbox1,但没有显示在屏幕上.我有许多其他控件和一个母版页.文本框位于更新面板中.

I am using ASP.NET and C# couple text boxes to calculate results entered. Textbox2 has a value entered and on button click Textbox1 gets populated. 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. I have many other controls and a master page. The textboxes are within an update panel.

有人可以帮我看看这是怎么回事吗?

Can someone help me what's going on?

代码如下:

<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" /> 

推荐答案

检查 page_load 函数中的回发.

Check the postback in the page_load function.

if(!Page.IsPostBack) {

}

我认为您在回帖时丢失了信息.数据已更改,但会在回发时重置.

I think you are loosing information on post back. The data is changed, but it get reset on post back.

这篇关于asp.net 文本框在回发后不会填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆