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
Loading

Riddhi ValechaPosted Apr 12, 2015, 7:34 AM
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();