humour
Programmer
- Nov 24, 2003
- 87
What I want to do is have a general class function that I can instantiate on any of my intranet pages and have it check for a cookie (which stores my employee id). No cookie found the code will redirect to a page and ask you for it (pretty simple). I do it in ASP but the function is part of an include.
How I want to do it in vb.net is to pass (ME) which is inherited from System.Web.UI.Page and pass it byRef into the function so I can invoke the cookie request function.
My code is below - the error I get is:
Object reference not set to an instance of an object.
Public Function LoadPage()
Dim sRC As String
' Me is the webform page (inherited from
' System.Web.UI.Page of course
sRC = pc.GetEmployeeIdCookie(Me)
Class ParamClass
Function GetEmployeeIdCookie(ByRef vWebPage As System.Web.UI.Page) As String
Dim EmpID As String
'EmpID = vWebPage.Request.Cookies("a")
EmpID = vWebPage.Request.Cookies("jjemployeeid").ToString
If Len(EmpID) < 1 Then
EmpID = ""
vWebPage.Response.Redirect("test.asp")
End If
Return EmpID
End Function
How I want to do it in vb.net is to pass (ME) which is inherited from System.Web.UI.Page and pass it byRef into the function so I can invoke the cookie request function.
My code is below - the error I get is:
Object reference not set to an instance of an object.
Public Function LoadPage()
Dim sRC As String
' Me is the webform page (inherited from
' System.Web.UI.Page of course
sRC = pc.GetEmployeeIdCookie(Me)
Class ParamClass
Function GetEmployeeIdCookie(ByRef vWebPage As System.Web.UI.Page) As String
Dim EmpID As String
'EmpID = vWebPage.Request.Cookies("a")
EmpID = vWebPage.Request.Cookies("jjemployeeid").ToString
If Len(EmpID) < 1 Then
EmpID = ""
vWebPage.Response.Redirect("test.asp")
End If
Return EmpID
End Function