Annoying exception in asp.net
all; I have this problem in asp.net, I have a page where I insert and modify data, before saving I do a check if it passes. I save the data, but if I don't throw an exception and show it, the function looks like this:
protected void btnSave_Click(object sender, EventArgs e)
{
try
{
...
if(ValidData())
//Save
...
else
throw new Exception("Invalid data");
}
catch(Exception ex)
{
// Javascript alert
JSLiteral.Text = Utilities.JSAlert(ex.Message);
}
}
The problem is that after I throw an exception and fix the data on the page, I hit the save button again and save it, but before it shows me the exception message again and is annoying. Even when the data is saved, I click again and again throws the message from the exception.
Do you know the answer to this question?
0
source to share
6 answers