Use of RegularExpressionValidator in MS .Net Framework
Posted
by Lawk Salih
on Stack Overflow
See other posts from Stack Overflow
or by Lawk Salih
Published on 2010-04-26T15:29:44Z
Indexed on
2010/04/26
15:33 UTC
Read the original article
Hit count: 237
Hi-
I am trying to use the RegularExpressionValidator Control in Visual Studio to validate a textbox for email address expressions.
Here's my code (very basic)
Email:
<input id="Text1" type="text" /><br />
<br />
<input id="Validate" type="button" value="Validate" runat="server" /><br />
<br />
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
ErrorMessage="RegularExpressionValidator" ControlToValidate="Validate"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
Now, when I set controlToValidate to Validate, I get the following error message:
Server Error in '/' Application.
Control 'Validate' referenced by the ControlToValidate property of 'RegularExpressionValidator1' cannot be validated. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: Control 'Validate' referenced by the ControlToValidate property of 'RegularExpressionValidator1' cannot be validated.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[HttpException (0x80004005): Control 'Validate' referenced by the ControlToValidate property of 'RegularExpressionValidator1' cannot be validated.] System.Web.UI.WebControls.BaseValidator.CheckControlValidationProperty(String name, String propertyName) +8734357 System.Web.UI.WebControls.BaseValidator.ControlPropertiesValid() +40 System.Web.UI.WebControls.BaseValidator.get_PropertiesValid() +21 System.Web.UI.WebControls.BaseValidator.OnPreRender(EventArgs e) +27 System.Web.UI.Control.PreRenderRecursiveInternal() +80 System.Web.UI.Control.PreRenderRecursiveInternal() +171 System.Web.UI.Control.PreRenderRecursiveInternal() +171 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +842
Version Information: Microsoft .NET Framework Version:2.0.50727.3607; ASP.NET Version:2.0.50727.3082
I have tried the same mechanism before and have worked; however, this time I am on a new machine, WinXP Pro running IIS v5.1.
Any direction would be appreciated.
© Stack Overflow or respective owner