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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Rafeeq Mohamed112 reputationPosted Dec 7, 2011, 7:49 PM EST
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
Nethra R SRank #6,347 · 269 reputationPosted Dec 7, 2011, 7:57 PM EST
I want to display a box using ajax how to do that. please help
Rafeeq Mohamed112 reputationPosted Dec 7, 2011, 8:09 PM EST
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