Use Session variable in html

前端 未结 2 1574
忘了有多久
忘了有多久 2020-12-06 01:58

I get a session variable from a login form and then redirect to another page:

    String a = Login1.UserName;
    Session[\"user\"] = a;
    Re         


        
相关标签:
2条回答
  • 2020-12-06 02:42

    Use a code block:

    Hello <%:Session["user"]%>
    

    Or if before .NET 4.0:

    Hello <%=Server.HtmlEncode(Session["user"])%>
    
    0 讨论(0)
  • 2020-12-06 02:42

    I was actually trying a lot to get my session value from a page to another html in asp.net.

    However some syntactical error was always acting as an hindrance.

    In order to solved it, I've created a web page and there I initiated the session in the code behind and directed that to the other page.

    Note, this is a .html page, so now in the body I used

    Hello <%=Session["UserID"]%>
    

    instead of

    Hello <%:Session["user"]%>
    

    (which wasn't working) and it fetched the value from my .cs to my .html file.

    0 讨论(0)
提交回复
热议问题