ascx form problem

Discussion in 'ASP.NET / ASP.NET Core' started by silkkeng, Dec 19, 2005.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. Hi, I put my form validation on ascx form.
    And It seems to me everytime keep getting form error.
    I was trying to use javascripts to do form validation.
    And also if I code behind ascx file, is it gonna work exactly like aspx ?
    function FormValidation {
    if (document.forms.loginform.txtusername.value == "")
    { alert("Please enter your username !");
    document.forms.loginform.txtusername.focus();
    return (false); }
    if (document.forms.loginform.txtpassword.value == "")
    { alert("Please enter your password !");
    document.forms.loginform.txtpassword.focus();
    return (false); }
    return true;
    }
    </script><form id=loginform method=post target=_self onsubmit="Return FormValidation">

    </Form>

    DK
     
  2. Hello,


    Regardless of the method you are using, did you try the validation controls of asp.net ? It is very easy to put the validation controls on your ascx page.
    1. put a "required validation control" on your ascx page
    2. set the "control to validate" property to the input you wish to validate
    3. set the proper error message
    4. optional: you might put a summury validation control on your page. If you set the text properties of the other validation controls to '*' and a user forgets to fill in this control, the '*' will appear and the error message itself will appear in the summary.


    in the following url, you see the validation controls at work (it is asp.net 2.0, but the idea behind it is the same).
    http://66.129.71.130/QuickStartv20/aspnet/samples/validation/RequiredFieldValidator_vb.aspx

    Success !

    --
    Steurm
    www.steurm.net/steurm
    [​IMG]
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page