Adding a constant variable to a ValidationExpression in ASP.net VB

Epissioro

New Member
I'm trying to create a global variable that I can set to multiple RegularExpressionValidators in the ValidationExpressions attribute. I want to be able to write something like:\[code\]ValidationExpression = "<%=ConstantVariable%>"\[/code\]but so far I haven't been able to get it to work. I have managed to output the Validation String I want to test against nested between two span tags. However, when I click update, the validation doesn't want to work.I have the below code which is part of my DetailsView.\[code\]<EditItemTemplate> <asp:TextBox Text='<%# Bind("first_name") %>' runat="server" ID="txtfirstname" MaxLength="30" /> <br /> <span>Here:<%=CustomRegex.StaffDetails.firstName%></span> <asp:RegularExpressionValidator ID="FirstNameRegularExpressionValidator2" runat="server" ErrorMessage="Please enter your first name correctly <%=CustomRegex.StaffDetails.firstName%>" ControlToValidate="txtfirstname" ValidationExpression='<%=CustomRegex.StaffDetails.firstName%>' Display="Dynamic" /> <asp:RequiredFieldValidator ID="FirstNameRequiredFieldValidator" runat="server" ErrorMessage="Please enter a first name." ControlToValidate="txtfirstname" display="Dynamic" /></EditItemTemplate>\[/code\]I also have the following in a vb file:\[code\]Namespace CustomRegex Public Class StaffDetails Public Shared firstName As String = "[a-zA-Z\-]+" End ClassEnd Namespace\[/code\]Does anyone have any ideas why its not working?
 
Back
Top