Spread for ASP.NET 8.0 Product Documentation > Developer's Guide > Customizing with Cell Types > Using Validation Controls |
You can prevent a user from entering invalid characters in a cell by using a validation control in the Spread cell.
Initialize the validation control and then add the validation control to the Spread cell.
You can use validation controls instead of the standard validation by setting the Validators property. The following cell types provide this option:
If the validation fails, the onErrorMessageShown event occurs and the user cannot change the active cell.
The validation is not supported if the ShowEditor property is true.
If you receive an error such as, "UnobtrusiveValidationMode requires a ScriptResourceMapping for 'jquery'" in Visual Studio 2012, then you may need to add the following information to web.config. <appSettings> |
This example creates a cell and assigns a basic validator to the cell.
Code |
Copy Code
|
---|---|
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator> |
C# |
Copy Code
|
---|---|
protected void Page_Load(object sender, System.EventArgs e) // RequiredFieldValidator, from toolbox // CompareValidator, from toolbox // CompareValidator, from code // RangeValidator, from toolbox // RangeValidator, from code |
VB |
Copy Code
|
---|---|
Protected Sub Page_Load(sender As Object, e As System.EventArgs) ' RequiredFieldValidator, from toolbox ' CompareValidator, from toolbox ' CompareValidator, from code ' RangeValidator, from toolbox ' RangeValidator, from code |