Validation errors in asp.net

Last post 07-06-2007 12:40 PM by PLBlum. 8 replies.

Sort Posts:

  • Validation errors in asp.net

    07-02-2007, 12:30 AM
    • Loading...
    • nitinver83
    • Joined on 06-05-2007, 7:20 PM
    • Posts 24

    i m a asp.net 2.0 developer

    i have a problem in validation sections

    some of the browser does not support javascript in tat case all the code is executed without any validations

    in asp.net1.1 we used the code

    if(!ivalid)

              return false;

    and all the validation code (java script code ) was converted into server code and validation were performed

    but this code is not working in the asp.net 2.0

    so plz help me with this

     

  • Re: Validation errors in asp.net

    07-02-2007, 2:57 AM

    Please give us some code snippet to describe your question

    Regards,
    Shobana
  • Re: Validation errors in asp.net

    07-02-2007, 5:25 AM
    • Loading...
    • nitinver83
    • Joined on 06-05-2007, 7:20 PM
    • Posts 24

    actually i want to know that when we apply the validations on our server controls like textbox , dropdownlist etc

    in IE  the javascrit is well supported  but in other browsers specially in Mozila firefox

    java script is not supproted. our validations does not work in that browser

    so i want to ask the sol to this problem

  • Re: Validation errors in asp.net

    07-02-2007, 5:30 AM
    • Loading...
    • kipo
    • Joined on 07-20-2006, 7:10 AM
    • Croatia
    • Posts 1,469

    Instead of this:

    if(!ivalid)
    use this:
    if (!IsValid)

  • Re: Validation errors in asp.net

    07-02-2007, 6:15 AM
    • Loading...
    • nitinver83
    • Joined on 06-05-2007, 7:20 PM
    • Posts 24

    Thanks for the kind help

     

  • Re: Validation errors in asp.net

    07-06-2007, 6:47 AM
    • Loading...
    • nitinver83
    • Joined on 06-05-2007, 7:20 PM
    • Posts 24

    this if(!IsValid)

    return false;

     

     

    is working fine in ASP.NET 1.1

    but not in ASP.NET 2.0

    pl help

     

    Filed under: ,
  • Re: Validation errors in asp.net

    07-06-2007, 7:31 AM
    • Loading...
    • dearviren
    • Joined on 06-21-2007, 10:26 AM
    • madrid
    • Posts 38

    protected void btnMCTAceptar_Click(object sender, EventArgs e)
            {
                string aeropuerto = this.txtaeropuerto.Text;
                string ciudad = this.txtciudad.SelectedItem.Text;
                string descriptionciudad = this.txtdescropcionciudad.Text;
                string pais = this.txtpais.Text;

                 if (validarForm(aeropuerto, ciudad, descriptionciudad,pais))

                   ,,,,,,
                  .....

             ]

     

             private Boolean validarForm(string aeropuerto, string ciudad, string descriptionciudad ,string pais)
                                      
            {
                string strError = "";
               
                if (aeropuerto.Equals("")) strError += "<li>El campo aeropuerto no puede estar vac&iacute;o.";
                if (ciudad.Equals("")) strError += "<li>El campo ciudad no puede estar vac&iacute;o.";
                if (descriptionciudad.Equals("")) strError += "<li>El campo descriptionciudad. no puede estar vac&iacute;o.";
                if (pais.Equals("")) strError += "<li>El campo pais no puede estar vac&iacute;o.";
                if (!strError.Equals(""))
                {
                    strError = "Se han encontrado los siguientes errores:<ul>" + strError + "</ul>";
                    mostrarError(strError);
                    return false;
                }
                else return true;
            }

    if code helps then mark as answer

     



    Virender singh
    MCA, CCNA
    System Analyst
    virender.singh@panel.es
    unisys.vsingh@iberia.es
    Virender.Singh@es.unisys.com
    VISION IS FUTURE
    Madrid( Spain)



  • Re: Validation errors in asp.net

    07-06-2007, 9:13 AM
    • Loading...
    • kipo
    • Joined on 07-20-2006, 7:10 AM
    • Croatia
    • Posts 1,469

    nitinver83:

    this if(!IsValid)

    return false;

     

     

    is working fine in ASP.NET 1.1

    but not in ASP.NET 2.0

    pl help

     

    Can you post your code, because it works fine in 2.0 too.
  • Re: Validation errors in asp.net

    07-06-2007, 12:40 PM
    Answer
    • Loading...
    • PLBlum
    • Joined on 06-28-2002, 9:20 AM
    • Boston, MA
    • Posts 5,155

    Perhaps you have tested IsValid in the wrong part of code.

    Validation is fired automatically by the Button control that submitted the page. It does so just before calling your Click event handler method and after Page_Load runs.

    Inside your Click event handler, test Page.IsValid is true. Only when true should you save or use the data from the form.

    If you are not using a button, have set the button to CausesValidation=false or are trying to validate in Page_Load, you must call Page.Validate() explicitly. You will still have to test Page.IsValid.

    --- Peter Blum
    Creator of Peter's Data Entry Suite (formerly Professional Validation And More and Peter's Date Package) and Peter's Polling Package
    www.PeterBlum.com
Page 1 of 1 (9 items)
Microsoft Communities
Page view counter