correct syntax to exclude tags

Discussion in 'ASP .Net Web Controls' started by Aamir Ghanchi, Apr 25, 2007.

  1. Hi,

    I need to exclude a control tag from an aspx page depending on the
    availability of a session variable.I try to enclose it in an if bloack
    as follows, but it seems to be not working.

    <% If Session("MySessionVariable") <> "" Then%>
    <MyUserCtrl:MyObj id="SearchResultNav" runat="server"></
    MyUserCtrl:MyObj>
    <% End If%>
    simply, I do not want the usercontrol tag to be included on the page
    if the session variable is not set.

    thanks.
    Aamir Ghanchi, Apr 25, 2007
    #1
    1. Advertising

  2. Aamir Ghanchi

    Ray Costanzo Guest

    It seems that you're thinking in Classic ASP terms here. How about using
    the codebehind file to control whether or not it's visible.

    codebehind:

    SearchResultNav.Visible = Session("MyVariable") <> ""

    Ray at work


    "Aamir Ghanchi" <> wrote in message
    news:...
    > Hi,
    >
    > I need to exclude a control tag from an aspx page depending on the
    > availability of a session variable.I try to enclose it in an if bloack
    > as follows, but it seems to be not working.
    >
    > <% If Session("MySessionVariable") <> "" Then%>
    > <MyUserCtrl:MyObj id="SearchResultNav" runat="server"></
    > MyUserCtrl:MyObj>
    > <% End If%>
    > simply, I do not want the usercontrol tag to be included on the page
    > if the session variable is not set.
    >
    > thanks.
    >
    Ray Costanzo, Apr 25, 2007
    #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. joon
    Replies:
    1
    Views:
    505
    Roedy Green
    Jul 8, 2003
  2. Dan

    correct or not correct?

    Dan, Oct 2, 2003, in forum: HTML
    Replies:
    7
    Views:
    425
  3. Aamir Ghanchi

    correct syntax to exclude tags

    Aamir Ghanchi, Apr 25, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    301
    Ray Costanzo
    Apr 25, 2007
  4. J.Ram
    Replies:
    7
    Views:
    636
  5. Replies:
    0
    Views:
    258
Loading...

Share This Page