How to change the label text?

Last post 11-24-2006 9:37 AM by just_life. 3 replies.

Sort Posts:

  • How to change the label text?

    11-22-2006, 2:59 PM
    • Loading...
    • just_life
    • Joined on 10-03-2006, 10:42 AM
    • Posts 31

    Hi,

    I have 3 fields and a submit button on page1.aspx. On clicking the "submit" button, it does a bunch of stuff and goes to page2.aspx 

    If field 1 AND field 2 on page1.aspx are empty/null, I want a label to show the text "enter 1 of the fields" else it successfully goes to page2.aspx.

    Please help in pointing to the code required.

    Thanks

    just_life

  • Re: How to change the label text?

    11-22-2006, 3:04 PM
    Darrell Norton, MVP
    Darrell Norton's Blog


    Please mark this post as answered if it helped you!
  • Re: How to change the label text?

    11-22-2006, 6:34 PM
    Answer
    • Loading...
    • Haissam
    • Joined on 10-05-2006, 6:25 AM
    • Beirut - Lebanon
    • Posts 4,730

    Dear,

    the code below will do the job

    if(TextBox1.Text && TextBox2.Text == "")

    {

    label1.Text = "Enter 1 of the fields";

    }

    else

    {

    Response.Redirect('page2.aspx");

    }

    this code works fine but instead you can use 2 requiredFieldValidators set their ControlToValidate property to each fields you have and set its Text property to "This field cannot be empty";

    Happy coding 

    Haissam Abdul Malak
    MCAD.NET
    | Blog |
  • Re: How to change the label text?

    11-24-2006, 9:37 AM
    Answer
    • Loading...
    • just_life
    • Joined on 10-03-2006, 10:42 AM
    • Posts 31

    Thank you very much. My postback was creating the issue( it was clearing up my label.text).

     

Page 1 of 1 (4 items)
Microsoft Communities
Page view counter