CustomValidator Does Not Work

Asked 2 years ago, Updated 2 years ago, 100 views

I have a question about asp.net

When I used CustomValidator, I couldn't debug to the control.
Not working

☆View

<asp:TextBox ID="TextBox18" runat="server"Text="></asp:TextBox>
    <br of >       
    <asp:CustomValidator ID="CustomValidator1" runat="server"
         ErrorMessage="No asp.net" ControlToValidate="TextBox18" OnServerValidate="CustomValidator1_ServerValidate">/asp:CustomValidator><br/>
    <asp:Button ID="Button5" runat="server" Text="Send"/>

☆Control

protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgsargs)
    {
        var text = args.Value;
        if(text.IndexOf("asp.net")>=0)
        {
            args.IsValid=true;
        }
        else
        {
            args.IsValid=false;
        }
    }

Is there anything wrong with the above?Please teach me><

asp.net

2022-09-30 21:12

1 Answers

There are no defects.

I tried debugging with the above source, but after pressing the send button
CustomValidator1_ServerValidate is invoked correctly.


2022-09-30 21:12

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.