locked
validation not working RRS feed

  • Question

  • User-198964422 posted
    HI, i have a web application which contain a login page i have deployed the application in the server and maeked login page as start page , so when i am running the application and without entering the uid and pwd i am clicking the submit button no server side message is displaying but when i am clicking 2nd time i am recieving the server message for required field so for example if teh browser address is http://servername/application/----the click event not working but when the browser adddress is http://servername/application/login.aspx---the click event is working thanks in advance
    Friday, August 30, 2013 12:27 AM

Answers

  • User-198964422 posted
    HI ramu, i have implemented another method i added another page . in the page load of that page i have written response.redirect to login page and make that new page as start of page and now its working
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, August 30, 2013 2:47 AM

All replies

  • User-306750178 posted

    Hi,

    It is always better to use client side validations (asp.net Required field validation controls/javascript) to validate the fields.

    Anyhow may below code help you.

    Call "validation()" method in your click event

    private bool validation() 
    { 
        if (txtFName.Text == string.Empty) { Alert("Invalid Name"); return false; } 
    
        if (txtLName.Text == string.Empty) { Alert("Invalid Name"); return false; } 
    } 

    Alert Method.

     // Alert mesage 
    public void Alert(string msg) 
    { 
        ClientScript.RegisterStartupScript(typeof(Page), "SymbolError", "<script type='text/javascript'>alert('" + msg + "');</script>"); 
    } 

    Click Event

    Private void Button1_Click(object sender, EventArgs e)
    {
       if(validation())
    //Do something
     }
    Friday, August 30, 2013 12:58 AM
  • User-198964422 posted
    HI Ramu, Client side validation is working cannot we do it using server side valiation
    Friday, August 30, 2013 1:06 AM
  • User-306750178 posted

    Try above code which is server side and let me know.

    Friday, August 30, 2013 1:08 AM
  • User-198964422 posted
    HI Ramu , the method is also not working since the Default page is missing in the browser
    Friday, August 30, 2013 1:53 AM
  • User-306750178 posted

    Send your code once. So that I will help you better.

    Friday, August 30, 2013 2:09 AM
  • User-198964422 posted
    HI ramu, i have implemented another method i added another page . in the page load of that page i have written response.redirect to login page and make that new page as start of page and now its working
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, August 30, 2013 2:47 AM