This customization displays a custom error message when adding a
record with a duplicate primary key.
This customization overrides the Validate() method and checks to see if a duplicate record exists.
If the record exists, an exception is thrown to display the custom error message.
When an exception is thrown in the Validate() method, it is caught in the SaveButton_Click handler.
The SaveButton_Click handler calls RegisterJScriptAlert to display the error message to the user.
Throwing an exception ensures that the record will not be saved. The record is saved if an exception is not thrown.
For a Web Application the customization will be added in:
..\<Application Name>\<Table Name>\Add<Table Name>.Controls.cs
For example: C:\MyApp1\Customers\AddCustomers.Controls.cs
For a Web Site the customization will be added in:
..\<Application Name>\App_Code\<Table Name>\Add<Table Name>.Controls.cs
For example: C:\MyApp1\App_Code\Customers\AddCustomers.Controls.cs
|