asp.net – 如何在单击“提交”按钮后显示requiredfieldvalidato
发布时间:2020-12-16 00:04:29 所属栏目:asp.Net 来源:网络整理
导读:现在,如果我移出当前文本框,将显示错误消息.在点击提交按钮之前我不想显示它. 解决方法 为验证程序启用ClientScript时,这是不可能的.默认情况下,为验证程序启用ClientScript.您需要通过在源中将EnableClientScript设置为False来禁用此功能. 现在,在提交按钮
现在,如果我移出当前文本框,将显示错误消息.在点击提交按钮之前我不想显示它.
解决方法
为验证程序启用ClientScript时,这是不可能的.默认情况下,为验证程序启用ClientScript.您需要通过在源中将EnableClientScript设置为False来禁用此功能.
现在,在提交按钮的事件处理程序中,调用Page.Validate()和Page.IsValid来查看每个验证器是否都通过了测试. 例: <asp:RequiredFieldValidator ID="rfvFirstName" runat="server" ControlToValidate="txtFirstName" EnableClientScript="false" Display="Dynamic" SetFocusOnError="true" /> Page.Validate(); if (!Page.IsValid) { //show a message or throw an exception } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net-mvc – 无法在实体框架模型中的MVC 4模板中使用Use
- asp.net – 使用itemtemplate动态地将列添加到Grid-view
- ASP.Net:将客户端onClick添加到GridView中的HyperlinkFiel
- asp.net – 在本地主机(Chrome和FF)上过期不到1年时未设置c
- asp.net-mvc-3 – ASP.NET MVC中全局错误/异常处理的最佳实
- asp.net – 为什么Jet OLEDB驱动程序缓存我的MDB文件?
- 如何在ASP.NET中继器DataDataBound事件中访问数据源字段?
- asp.net-mvc – 确保每个控制器方法都有一个ValidateAntiFo
- asp.net-mvc-3 – 带有重音IE8的ASP MVC3 FileResult – 被
- asp.net-mvc – IdentityServer MVC令牌过期
推荐文章
站长推荐
- asp.net – 我是否需要viewstate来输入控件,如复
- asp.net – Internet Explorer中的图像加载超时
- asp.net-mvc – mvc – 页面标题 – 两种不同的设
- asp.net – 如何刷新.dbml同步到数据库
- asp.net-mvc – Asp.net mvc 4部署错误
- MVC 文件夹
- asp.net-mvc – 在Controller或其他地方渲染部分
- dependency-injection – ActionFilterAttribute
- asp.net-web-api – 默认使用ASP.NET Web API返回
- 使用ASP.NET和global.asax进行速率限制
热点阅读