我的aspx.page我有一行:
<asp:Label ID="EmailLabel" runat="server" AssociatedControlID="Email">E-Mail</asp:Label>
<asp:TextBox ID="Email" runat="server" TabIndex="4" CssClass="textEntry" CausesValidation="True"></asp:TextBox>
<%MailValidation(Email.Text)%>
<asp:RegularExpressionValidator runat="server" ID="RegExpValidator"
CssClass="failureNotification"
SetFocusOnError="True" ControlToValidate="Email"
ErrorMessage="<%= ValReturnTxt %>"
ValidationGroup="RegisterUserValidationGroup">@</asp:RegularExpressionValidator>
在我的代码背后,我有:
Public ValReturnTxt As String
Public Sub MailValidation(mail As String)
'Dim retVal As String
Dim s As Internet = New Internet
Dim boolVal As Boolean = IsValidEmail(mail)
ValReturnTxt = Internet._error
End Sub
后面的代码运行得很好,随时给出了我想要的答案。
Internet是命名空间public class
内的Network
第<%MailValidation(Email.Text)%>
行就像我期待的那样
我的问题是,我无法在我的ValReturnTxt
ErrorMessage="<%= ValReturnTxt %>"
中的RegularExpressionValidator
作为txt答案进行分配
答案 0 :(得分:1)
您可以访问Sub MailValidation()中的控件“RegExpValidator”。
Public Sub MailValidation(mail As String)
Dim s As Internet = New Internet
Dim boolVal As Boolean = IsValidEmail(mail)
RegExpValidator.ErrorMessage = Internet._error ' I added this line.
End Sub