未声明名称“会话" [英] Name 'Session' is not declared
本文介绍了未声明名称“会话"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好朋友,
当我加载ASP.Net 2008项目时,经常在文件后面的VB代码中出错,例如上面发布的代码.有时,它销售未定义的文本框对象或标签,即使它定义了,结果也导致我无法加载我的项目.我的代码如下所示:
Hello Friends,
When I load my ASP.Net 2008 project, I often get errors in the VB code behind file such as the one posted above. Sometimes, it sales a textbox object or label is not defined, even if it is and as I result I cannot load my project. My code looks like this one:
On Error GoTo Err_Page_Load
Dim strMsg As String
If Session("GLSys") = True Then
mnuMainMenu.Items(1).Enabled = True
End If
lblUserName.Text = Session("UserName")
lblPeriodNumb.Text = Session("PeriodNumb")
strMsg = CStr(session("StartDate")) & "-" & CStr(session("EndDate"))
'lblDateRange.Text = Session("StarDate").ToString
'lblDateRange.Text = lblDateRange.Text & "-" & Session("EndDate").ToString
lblDateRange.Text = strMsg
lblAcctYear.Text = Session("CurrYear").ToString & "-" & Session("NextYear").ToString
lblLocCurrCode.Text = Session("LocCurrCode")
lblDateClock.Text = DateTime.Today.ToString
lblCoyName.Text = Session("CoyName") '& "->" & Session("BranchCode")
lblCopyright.Text = Session("ProgTitle")
imgCoyLogo.ImageUrl = "~/Images/CoyLogo.jpg"
Exit_Page_Load:
Exit Sub
Err_Page_Load:
lblStatus.Text = lblStatus.Text & "Error No : " & Err.Number.ToString & "->" & Err.Description & " has occurred!" & Chr(13)
lblStatus.Visible = True
Resume Next
有人可以帮忙吗!我该如何解决此问题以及为什么会收到这些类型的消息.
谢谢大家!
Sylvester
Could someone please help! How can I solve this problem and why do I get these types of messages.
Thanks to all!
Sylvester
推荐答案
尝试这个
HttpContext.Current.Session("key")=值"
try this one
HttpContext.Current.Session("key") = "value"
这篇关于未声明名称“会话"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文