vb.net 如何在 asp.net 中使用 Javascript 分配会话变量
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26463858/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to Assign Session variables using Javascript in asp.net
提问by Dhibi_Mohanned
I want to Assign session variable using java script. I find this code that works fine
我想使用 java 脚本分配会话变量。我发现这段代码工作正常
function SetUserName()
{
var userName = "Shekhar Shete";
<%Session["UserName"] = "' + userName + '"; %>;
alert('<%=Session["UserName"] %>');
}
The problem that i use vb.net as language and not c#. I want have the same code with vb.net. Does anybody have any suggestion to resolve this problem?
我使用 vb.net 作为语言而不是 c# 的问题。我想要与 vb.net 相同的代码。有没有人有任何建议来解决这个问题?
Thanks a lot in advance.
非常感谢。
回答by Tushar
For VB.Net you can rewrite the same as
对于 VB.Net,您可以重写与
<%Session("UserName") = "' + userName + '"%>
alert('<%=Session("UserName") %>');
Also if you want to convert your piece of code from c# to VB , you can take help from : http://www.developerfusion.com/tools/convert/csharp-to-vb
此外,如果您想将您的代码从 c# 转换为 VB,您可以从以下位置获取帮助:http: //www.developerfusion.com/tools/convert/csharp-to-vb
回答by F0r3v3r-A-N00b
<%Session(userName) = "' + userName + '"%>
alert('<%=Session(userName) %>');

