简体   繁体   中英

asp.net RequiredFieldValidator with custom control

I have custom control with asp textbox inside.

And i need to Validate by RequiredFieldValidator my custom control on CLIENT side.

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

<asp:CustomValidator ID="CustomValidator1" runat="server" ClientValidationFunction="ValidateCheckBox"
ErrorMessage="Please enter something.">

ClientValidationFunction is the name of your javascript function

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM