Conditional user interface in ASP.NET

Discussion in 'ASP .Net Web Controls' started by Terence, Oct 28, 2003.

  1. Terence

    Terence Guest

    Dear all,

    I am converting an asp application to aspx and encountered a problem.
    The problem is that i need output different html code based on some
    condition. For example,
    in asp, there is a variable (let say, bEditMode), if bEditMode= false, then
    the page display the value in text.
    If the bEditMode = true, then it should display textbox rather than just the
    text.
    In asp, it can be done easily by:

    if bEditMode Then
    Response.Write "User Name from database"
    Else
    Response.Write "<input type=""text"" />"
    End If

    How can I do this in aspx ?

    Thanks in advance.

    Terence
    Terence, Oct 28, 2003
    #1
    1. Advertising

  2. Terence

    Oliver Guest

    Hi Terence,

    The easiest way is to put both controls on the page. Then you can just
    switch their Visible property:

    Label1.Visible = bEditMode
    TextBox1.Visible = Not bEditMode

    Of course you could get fancy and create the controls in code and assign
    them to a placeholder control but it probably isn't worth the effort.




    "Terence" <> wrote in message
    news:...
    > Dear all,
    >
    > I am converting an asp application to aspx and encountered a problem.
    > The problem is that i need output different html code based on some
    > condition. For example,
    > in asp, there is a variable (let say, bEditMode), if bEditMode= false,

    then
    > the page display the value in text.
    > If the bEditMode = true, then it should display textbox rather than just

    the
    > text.
    > In asp, it can be done easily by:
    >
    > if bEditMode Then
    > Response.Write "User Name from database"
    > Else
    > Response.Write "<input type=""text"" />"
    > End If
    >
    > How can I do this in aspx ?
    >
    > Thanks in advance.
    >
    > Terence
    >
    >
    Oliver, Oct 29, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Wildepiet
    Replies:
    0
    Views:
    1,850
    Wildepiet
    Jun 14, 2004
  2. cyberco
    Replies:
    8
    Views:
    480
    cyberco
    Feb 25, 2006
  3. Alec S.
    Replies:
    10
    Views:
    10,091
    Alec S.
    Apr 16, 2005
  4. =?Utf-8?B?S2Vubnk=?=
    Replies:
    1
    Views:
    2,394
    sloan
    Aug 15, 2006
  5. Replies:
    2
    Views:
    332
    Peter
    Aug 7, 2008
Loading...

Share This Page