hi folks,
I write code in textbox textchnage event and bind all textbox .and and check the textbox is empty or not and write business logic.but problem is that .now the problem is that when the textbox is empty and press enter (i bind enter key to keypress) but event is not fired .but i write something then it works fine for me.
othewise how i get on page load to which textbox is sender .
Please share some link
How to get the which textbox event fired in asp.net
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.


Riddhi ValechaRank #794 · 2.9K reputationPosted Apr 12, 2015, 3:34 AM EDT
As far as I am getting your query, you just want to check whether a textbox is empty or not..
Make a method and call it on button_clicl -
Eg -
private String CheckTextBox()
{
try
{
if(txtbox1.text.Lenght > 0)
{
if(txtbox2.text.lenght > 0)
{
return null;
}
else return "Enter value in text box 2";
}
else return "Enter value in textbox1";
}
catch(Exception err){return err.Message.ToString();}
}
---
On Button_Click
If(CheckTextBox() == null)
{
//proceed
}
else errormessage = CheckTextBox().ToString().Trim();