Asp.net自定义验证器

编程入门 行业动态 更新时间:2024-10-22 02:38:51
本文介绍了Asp自定义验证器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

大家好, 在我的代码后面使用自定义验证器使用ASP.NET C# i在我的应用程序中返回以下代码 实际上代码在我的结束时工作正常,但错误的方式 但是我需要以下选项,比如我们, char应该是min 5到10 我的代码是:

hi all, am using custom validator on my code behind using ASP.NET C# i have return below code in my application actually the code was working fine on my end but the wrong way but i need the below option such us, the char should be min 5 to 10 my code is:

server side code: protected void TextValidate(object source, ServerValidateEventArgs args) { args.IsValid = (args.Value.Length == 5); } client side code: <asp:textbox id=TextBox1 runat="server"></asp:textbox> <asp:CustomValidator id="CustomValidator1" runat="server" OnServerValidate="TextValidate" ControlToValidate="TextBox1" ErrorMessage="the char should be min 5 to 10."> </asp:CustomValidator>

所以请看看我的代码, i尝试了很多其他方式,但我不能。 感谢所有

so please have a look at my code, i have tried many other way but i cant. thanks to all

推荐答案

您可以申请以下代码: You can apply below code : <asp:textbox id="TextBox1" runat="server" xmlns:asp="#unknown"></asp:textbox> <asp:regularexpressionvalidator display="Dynamic" controltovalidate="TextBox1" id="RegularExpressionValidator3" validationexpression="^[\s\S]{5,10}

runat = server errormessage = 最少5个字符和最多10个字符。 xmlns:asp = #unknown > < / asp:regularexpressionvalidator > " runat="server" errormessage="Minimum 5 and Maximum 10 characters required." xmlns:asp="#unknown"></asp:regularexpressionvalidator>

您是否尝试过以下声明。 Have you tried below statement. args.IsValid = (args.Value.Length >= 5 && args.Value.Length <= 20);

更多推荐

Asp.net自定义验证器

本文发布于:2023-11-11 07:07:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1577724.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:自定义   Asp   net

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!