Click here to Skip to main content
16,020,261 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:

VB
        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



Could someone please help! How can I solve this problem and why do I get these types of messages.

Thanks to all!
Sylvester
Posted
Updated 16-Sep-11 23:50pm
v2
Comments
DaveAuld 17-Sep-11 5:50am    
Edit: Added code formatting
Utuba 17-Sep-11 6:15am    
Thanks Salini! I have tried Square brackets '[]' around the Sesssion but it does not work! In fact it increases the number of errors for me!
P.Salini 17-Sep-11 6:20am    
sorry your code is correct
I thought it is c#
so i asked u to changes to square braces but no need of it
P.Salini 17-Sep-11 7:06am    
check whether your page contain reference to system.web or not

1 solution

try this one

HttpContext.Current.Session("key") = "value"
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900