验证控件不会阻止对服务器的回发请求
我有一个很大的网页,其中有 TextBox 和RequiredRangeValidator。
<asp:textbox id="tbNewSvrLic" runat="server" Text="0" BackColor="#FFFFA0" />
<asp:RangeValidator id="NewSvrLicValidator" ControlToValidate="tbNewSvrLic"
runat="server" Type="Integer" MinimumValue="0" MaximumValue="5"
errormessage="Invalid value specified for Additional Server Licenses"
Display="Dynamic" />
<asp:button id="btnOrderSummary" OnClick="btnOrderSummary_Click"
runat="server" text="Display" Visible="False" />
这些控件在页面第一次加载时不可见,但在用户在页面上执行一些操作并向服务器提交一些数据后变得可见(可见状态将更改为 true)。
当无效数据(例如 10 个值)输入“tbNewSvrLic”控件时,会显示所需的错误消息,但“显示”按钮仍然可单击,并向服务器发出回发请求。
网站在 .NET 4.0 下运行,.NET 3.5 实现了非常相似的功能,但按预期工作...
请告知。欢迎任何想法。
PS 也许我需要提到错误消息(在验证控件上)显示为黑色,而不是像平常那样显示为红色......
I have big web page, among other there is TextBox and RequiredRangeValidator.
<asp:textbox id="tbNewSvrLic" runat="server" Text="0" BackColor="#FFFFA0" />
<asp:RangeValidator id="NewSvrLicValidator" ControlToValidate="tbNewSvrLic"
runat="server" Type="Integer" MinimumValue="0" MaximumValue="5"
errormessage="Invalid value specified for Additional Server Licenses"
Display="Dynamic" />
<asp:button id="btnOrderSummary" OnClick="btnOrderSummary_Click"
runat="server" text="Display" Visible="False" />
These control are non visible when page is loaded 1st time, but became visible after user do some actions on page and submit some data to server (there Visible status will be changed to true).
When invalid data (for example 10 value) is entered into 'tbNewSvrLic' control then required error message is displayed, but 'Display' button is still clickable and does post-back request to server.
Web site is working under .NET 4.0, very similar functionality is implemented for .NET 3.5, but works as expected...
Please advise. Any thoughts are welcome.
P.S. Probably I need to mention that error message (on validation controls) are displayed in black, not in red as usual...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以尝试使用此处提到的ValidationGroups吗?
Can you try using ValidationGroups as mentioned here ?