Custom validators...

Posted on 2005-05-09
Last Modified: 2010-04-07
Is there a way to design a custom validator that only presents a warning and will allow the user to continue?

Question by:Weller0123
    LVL 33

    Accepted Solution

    Yes, are we talking about client-side or server-side?

    It's always up to you on the server of what to do, you just check Page.IsValid()

    On the client, you'd just have to design a message to alert them, but still set the validator valid=true.
    LVL 24

    Assisted Solution

    by:Jeff Certain
    Yes... create a custom validator that sends uses this as the validation function:

    args.IsValid = true;
    LVL 24

    Expert Comment

    by:Jeff Certain

    Using a custom validator does both... at least according to Microsoft**. Specifying the javascript validation function will run client-side scripting if javascript is enabled, and validate server-side (using Page.IsValid)  if javascript is not enabled.

    Of course, you know all this already ;)


    ** warning: this claim is made by Microsoft and has not been tested by the author. Like most MS claims, your mileage may vary... ;)
    LVL 23

    Assisted Solution

    <asp:CustomValidator Id="CustomValidator1" runat="server" Display="None" ClientValidationFunction="CustomValidator1_ClientValidate" />
    <asp:LinkButton Id="SaveButton" runat="server" CausesValidation="True">Save</asp:LinkButton>

    function CustomValidator1_ClientValidate(sender,args)
          bool value = false;
          if (<condition> = true)
                value = true;
          args.IsValid = value;
          if (! value)

    Private Sub CustomValidator1_ServerValidate(ByVal sender As Object, ByVal args As ServerValidateEventArgs) Handles CustomValidator1.ServerValidate
          Dim value As Boolean = False
          If <condition> Then
                value = True
          End If
          args.IsValid = value
          If Not value Then
                Page.RegisterClientScriptBlock("display","<script language=""javascript"">window.onload = function () { alert(...) }</script>")
          End If
    End Sub

    Private Sub SaveButton_Click(ByVal sender As Object,ByVal e As EventArgs) Handles SaveButton.Click
          If Page.IsValid Then
          End If
    End Sub


    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Join & Write a Comment

    Suggested Solutions

    Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
    In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now