[英]asp.net RequiredFieldValidator with custom control
I have custom control with asp textbox inside. 我有自定义控件,里面有asp文本框。
And i need to Validate by RequiredFieldValidator my custom control on CLIENT side. 我需要通过RequiredFieldValidator验证我在CLIENT端的自定义控件。
I added attribute to custom control class: 我将属性添加到自定义控件类:
[ValidationProperty("Text")]
public class WatermarkTextBox : System.Web.UI.UserControl
{
}
It looks like working but it always make submit to server. 看起来像在工作,但总是使提交到服务器。 How can i check it only on client side? 我如何只在客户端上检查它?
You need to use a CustomValidator like this 您需要像这样使用CustomValidator
<asp:CustomValidator ID="CustomValidator1" runat="server" ClientValidationFunction="ValidateCheckBox"
ErrorMessage="Please enter something.">
ClientValidationFunction is the name of your javascript function ClientValidationFunction是您的javascript函数的名称
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.