1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

need to validate textbox

Discussion in 'C#' started by alicepriya, Aug 28, 2010.

  1. alicepriya

    alicepriya Guest

    how to validate textbox using errorprovider in c#

    please give me reply sir
     
  2. Ami Desai

    Ami Desai Member

    Joined:
    Jan 5, 2017
    Messages:
    42
    Likes Received:
    17
    Trophy Points:
    8
    Location:
    Ahmedabad
    Home Page:
    Hi,

    You can check this
    Code:
    void Txt_nameValidating(object sender, System.ComponentModel.CancelEventArgs e)
    {
    if(txt_name.Text==string.Empty)
    {
    errorProvider1.SetError(txt_name,"Please Enter Name");
    errorProvider2.SetError(txt_name,"");
    errorProvider3.SetError(txt_name,"");
    }
    else
    {
    errorProvider1.SetError(txt_name,"");
    errorProvider2.SetError(txt_name,"");
    errorProvider3.SetError(txt_name,"Correct");
    }
    }
    Thanks
     

Share This Page