Here's my Markup
这是我的标记
<asp:TextBox ID="txtCrdtCrdNumber" ValidationGroup="val1" MaxLength="16" CssClass="txt" tyle="background: url(images/txtboxcredit.png) no-repeat right; padding-right: 192px;width: 182px;border:1px solid #ccc;" runat="server" ></asp:TextBox>
<asp:RequiredFieldValidator ValidationGroup="val1" ID="reqtxtCrdtCrdNumber" ControlToValidate="txtCrdtCrdNumber" Display="Dynamic" ErrorMessage="Please Specify Card Number" runat="server">*</asp:RequiredFieldValidator>
It just dont prevent my page from loading, even if i don't specify anything in the textbox. What do i do?
即使我没有在文本框中指定任何内容,它也不会阻止我的页面加载。我该怎么办?
1 个解决方案
#1
To venture a guess: you might be clicking a button to trigger a page reload, and this button does not have a validation group specified.
猜测:您可能正在点击按钮来触发页面重新加载,并且此按钮没有指定验证组。
If there is a validation group defined, all relevant controls - buttons, inputs, validators - should indicate that they belong to the same validation group.
如果定义了验证组,则所有相关控件(按钮,输入,验证器)应指示它们属于同一验证组。
So:
<asp:Button runat="server" ... ValidationGroup="val1" />
#1
To venture a guess: you might be clicking a button to trigger a page reload, and this button does not have a validation group specified.
猜测:您可能正在点击按钮来触发页面重新加载,并且此按钮没有指定验证组。
If there is a validation group defined, all relevant controls - buttons, inputs, validators - should indicate that they belong to the same validation group.
如果定义了验证组,则所有相关控件(按钮,输入,验证器)应指示它们属于同一验证组。
So:
<asp:Button runat="server" ... ValidationGroup="val1" />