Hi,
I have added a UNIQUE constraint to 2 columns and i want to display a window to the user if they try to add duplicate values.. In asp.net how do i do this.. My insert code is in the try catch
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Rafeeq MohamedPosted Dec 8, 2011, 1:09 AM
In your application you can use try catch to throw the error to the ajax call, or you can customize your exception block to return it as a message.
In that case you need to modify your success block in Ajax call to check for error
Nethra R SPosted Dec 8, 2011, 12:57 AM
I want to display a box using ajax how to do that. please help
Rafeeq MohamedPosted Dec 8, 2011, 12:49 AM
You can handle exception in multiple ways..
1) by Using
public void Page_Error(Object sender, EventArgs e)
{
// Implementation here
}
2) by Using
public void Application_Error(Object sender, EventArgs e)
{
// Implementation here
}
3) If you are doing thru Ajax, you can show the box based on data returned.
Refer:
http://www.codeguru.com/csharp/.net/net_asp/miscellaneous/article.php/c12385
http://msdn.microsoft.com/en-us/library/aa479319.aspx
http://www.codeproject.com/KB/aspnet/ExceptionHandlingNET.aspx
http://www.codeproject.com/KB/aspnet/ErrorHandlingASPNET.aspx
Thanks,
Rafeeq