把一个会话变量为一个文本框 [英] Put a Session variable into a textbox
本文介绍了把一个会话变量为一个文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个会话变量
会话[的customerID]
我希望把这个文本框里面。我将如何做到这一点?
我已经试过
TextBox1.Text =会话[的customerID]
解决方案
如果(会话[的customerID]!= NULL)
{
TextBox1.Text =会话[的customerID]的ToString()。
}
我想补充一个空的检查,以确保如果会话变量是未定义的code不会失败
I have a Session variable
Session["customerID"]
I want to place this inside a textbox. How would I do this?
I have tried
TextBox1.Text = Session ["customerID"]
解决方案
if(Session["customerID"] != null)
{
TextBox1.Text = Session["customerID"].ToString();
}
I would add a null check to ensure that your code doesn't fail if the session variable is undefined
这篇关于把一个会话变量为一个文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文