Hey.
Server side:
protected TextBox txt;
protected Label lbl;
private void Page_Load(object sender,System.EventArgs e)
{
try
{
IsPostBack ? lbl.Visible = false : Verify();
}
catch(TextBoxIsNotValid)
{
lbl.Visible = true;
lbl.Text = "Whatever message";
}
}
private void Verify()
{
try
{
int.Parse(txt.Text.Trim());
}
catch
{
throw new TextBoxIsNotValid();
}
}
Separate class somewhere:
public class TextBoxIsNotValid : System.Exception
{
public TextBoxIsNotValid() : base("Some message to log if needed.");
}
Hope it'll help.
Kikoz
"sp" <sp@discussions.microsoft.com> wrote in message
news:26**********************************@microsof t.com...
Hello Everybody,
How can I restrict the user entering non-numeric data in textbox control
on server side using asp.net. Any Code sample or suggestions are
appreciated.
Thanks in advance
sp