Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
2
Reply
how to identify the empty textbox in asp.net
Abhijit Patil
Apr 11 2015 7:07 AM
848
Reply
hi folks,
In asp.net i bind all textbox to textchange event and get the sender value of textbox and do my operation.
textchange event is work fine .but problem is that when my textbox is empty and i pressed enter then the event is not fire.
how to solve my problem.
my code snippest as below
protected void txtName_TextChanged(object sender, EventArgs e)
{
TextBox tb = sender as TextBox;
if (tb.ID == "TextBox1")
{
if (tb.Text == string.Empty)
{
Label1.Text = "Please enter input";
}
else if (TextBox1.Text == "001")
{
Label1.Text = "user is valid";
TextBox2.Focus();
}
else
{
Label1.Text = "user is not valid";
TextBox2.Focus();
}
}
else if (tb.ID == "TextBox2")
{
if (tb.Text == string.Empty)
{
Label1.Text = "Please enter input";
}
else
{
Label1.Text = TextBox1.Text;
}
}
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
2
)
Next Recommended Forum
Gridview
how to get the which textbox event fired in asp.net