我在Visual Web developer 2008 Express Edition中执行此验证摘要程序,发现验证摘要属性在输出中不可见。请帮我解决这个问题!!提前致谢
<div><asp:ValidationSummary ID="sum1" runat ="server" ShowMessageBox="false" HeaderText="You details cannot be processed due to following errors:" DisplayMode="BulletList" ShowSummary ="true" Font-Names ="arial" Font-Size ="12"></asp:ValidationSummary>
<asp:CompareValidator ID="cmp1" runat ="server" ControlToValidate ="txtname" Display="Dynamic" Operator="DataTypeCheck" ControlToCompare="txtname1" Type="String" ErrorMessage="values does not match" >*</asp:CompareValidator>
<asp:RangeValidator ID="ran1" runat ="server" ControlToValidate ="txtdate" MinimumValue="01/08/2011" MaximumValue="31/08/2011" Type="Date" Display="Dynamic" ErrorMessage="Enter date between 1/8/2011 to 31/8/2011" >*</asp:RangeValidator>
<asp:CompareValidator id="cmp" runat ="server" ControlToValidate ="txtdate" Operator="DataTypeCheck" Type="Date" Display="Dynamic" ErrorMessage="You must date is format of dd/mm/yyyy" >*</asp:CompareValidator>
答案 0 :(得分:0)
您遇到的问题(至少使用第一个比较验证程序)是您正在执行DataTypeCheck(Type =“DataTypeCheck”)。
这意味着验证器只验证txtname的数据类型,在这种情况下,它被指定为String(Type =“String”),而不是将它与txtname1进行比较。
如果你需要检查txtname中的值是否等于txtname1,你应该使用Equal运算符。
CompareValidator.Operator Property
请参阅“备注”部分下的“DataTypeCheck”。