textbox.text总是返回空字符串,而不是用户输入的文字 [英] textbox.text always returning empty string instead of user's entered text
本文介绍了textbox.text总是返回空字符串,而不是用户输入的文字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我很惊讶地发现,昨晚我的code是工作的罚款,第二天突然我的textbox.text总是空字符串..结果
我的code是:
I am very surprised to see last night my code was working fine and the next day suddenly my textbox.text always have empty string..
My code is:
Name of Event* :
<br />
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
背后code:
protected void Page_Load(object sender, EventArgs e) {
}
protected void create_Click(object sender, EventArgs e) {
if (!object.Equals(Session["UserLoginId"], null)) {
int mid = 0;
int cid = 0;
bool valid = true;
if (this.TextBox1.Text == "") {
error.Text = "<p style='color:red'>Marked Fields are compulsory!!</p>";
}
else {
.... // database insert ....
}
我总是结束与一个error.text值。
I am always ending up with an error.text value.
为什么?
推荐答案
也有类似的问题,文本框获取有关添加新行清除。这是被点击Add按钮时,页面重新加载的问题。
Had a similar problem with text boxes getting cleared on adding a new row. It was the issue of the page reloading when the add button was clicked.
中加入修正该问题:
Sub Page_Load
If Not IsPostBack Then
BindGrid()
End If
End Sub
每微软的文档 http://msdn.microsoft.com/en-us /library/aa478966.aspx 。
这篇关于textbox.text总是返回空字符串,而不是用户输入的文字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文