SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Sep 2010
    0 Post(s)
    0 Thread(s)

    Session displayed in a aspx page

    In 4.0 I have a webpage say page1.aspx.

    In this page I want to add a Session("sessionval") to an

    <a href="><???Session("sessionval")???></a>

    so that the value of Session("sessionval") will show and be underlined an when clicked go to the link.

    Is this possible?

  2. #2
    SitePoint Mentor NightStalker-DNS's Avatar
    Join Date
    Jul 2004
    Cape Town, South Africa
    48 Post(s)
    0 Thread(s)
    Yes, that is possible, but would probably be better to do it from code behind. You can do something like this:
    <a href="" id="hrefSession" runat="server"></a>

    Then from code behind:
    hrefSession.InnerHTML = Session["sessionval"].ToString();

    or you can use .InnerText if it is only text. It is better to do it from code behind as you can easily wrap it in an if to check if session is not null before setting it and hiding it if it is.

    But if you really want to do it from the page and not code behind, you can do this:
    <a href="><%=Session("sessionval").ToString()%></a>

    I hope this helps


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts