如何在html中提供会话变量 [英] how to give session variable in html
问题描述
大家好,
我刚刚创建了一个会话变量.我想给它的价值在html(design view).如何在html
hello all,
i have just creates a session variable. i want to give its value in html(design view). how to write session in html
推荐答案
中编写会话您可以直接在页面上编写它:
You can write it directly on the page:
Response.Write(Session["sessionName"].ToString());
但是我更喜欢使用Label(提供span标签)或Literal(仅提供text属性).
在HTML中:
<asp:Label ID="lblResult" runat="server" />
并在代码隐藏(c#)中:
But I prefer to use a Label (renders a span tag) ou a Literal (renders just the text property).
In HTML:
<asp:Label ID="lblResult" runat="server" />
And in the codebehind(c#):
lblResult.Text = Session["sessionName"].ToString();
嗨
使用 HTML
< div>用户名:-<%=会话["UserName"]%></div>
Hi
using HTML
<div>User Name:- <%= Session["UserName"] %></div>
<div>User Name:- <%= Session["UserName"] %></div>
如有任何疑问,请让我知道.
请提供"投票":thumbsup:如果有帮助,请提供"接受答案",如果这是正确的答案.:rose:
谢谢,
Imdadhusen
Please do let me know, if you have any doubt.
Please provide "Vote":thumbsup: if this would be helpful, and make "Accept Answer" if this would be correct answer.:rose:
Thanks,
Imdadhusen
这篇关于如何在html中提供会话变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!