下面是代码,当我选择一个错误的文件类型时,我会立即看到红色的"*“,但我看不到验证摘要,并且有一个buton("upload"),当我单击它时,我会得到验证摘要错误消息。
我的问题是:当我选择了错误的文件类型时,为什么不显示验证摘要?
<asp:ValidationSummary ForeColor="DarkRed"
ID="ValidationSummary1" runat="server" ShowMessageBox="False"
HeaderText="To save this page, the following required fields must be completed:" ShowSummary="true" />
<asp:RegularExpressionValidator ID="RegularExpressionValidator2" EnableClientScript="true" runat="server" ControlToValidate="fUpload"
ValidationExpression="^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w].*))(.rtf|.RTF|.Rtf|.xls|.XLS|.Xls)$" Text="*"
ErrorMessage="Invalid file type" SetFocusOnError="true" Display="Dynamic">/></asp:RegularExpressionValidator> 发布于 2010-09-17 22:45:17
由于您的RegularExpressionValidator具有EnableClientScript="true",因此它将导致对该控件进行客户端验证。
即使ValidationSummary控件也可能被设置为EnableClientScript="true",它也必须验证具有其自己的组的所有控件,因此不会以相同的方式显示错误消息。这是经过设计的,所以只有在提交表单后才能工作。
要立即停止显示'*‘,可以将控件设置为Display="None"或更改为EnableClientScript="false"
https://stackoverflow.com/questions/3736170
复制相似问题