Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   Shared and object References (http://www.velocityreviews.com/forums/t116932-shared-and-object-references.html)

tshad 01-09-2006 04:12 AM

Shared and object References
 
I am trying to build a small shared routine that I call in all my pages. I
don't want to create an object reference as I just want to make a routine
that I can use to add in code that needs to be executed at the beginning of
all my pages with having to go change all the pages whenever this is needed.

Here is the routine I am setting up:
************************************************** *********
Imports System
Imports System.Web
Imports System.IO
Imports System.Web.UI
Imports System.Web.SessionState
Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.HttpCookie
Imports System.Web.HttpCookieCollection
Imports System.Web.HttpResponse
Imports System.Web.HttpRequest
imports System.Web.HttpContext
Imports System.Web.HttpApplication
Imports System.Web.HttpApplicationState
Imports System.Collections
Imports FtsData

NameSpace MyFunctions

Public Class PageLoad

Public Shared sub InitialPageLoad ()

HttpContext.Current.Session("User").LastPageVisite d =
System.Web.HttpContext.Request.ServerVariables("PA TH_INFO")

end sub

End Class
End Namespace
************************************************** **************************
*******

but I am getting an error on the System.Web.HttpContext.Request:

C:\Inetpub\wwwroot\staffingworkshop\Classes\PageLo ad.vb(26) : error BC30469:
Reference to a non-shared member requires an object reference.

I just want to get the server variable Path_Info to get the current page.

How can I do this without setting up an object reference?

Thanks,

Tom



=?Utf-8?B?U2VyZ2V5IFBvYmVyZXpvdnNraXk=?= 01-09-2006 04:47 AM

RE: Shared and object References
 
Try:

Dim context As HttpContext = HttpContext.Current
If Not context Is Nothing Then
context .Session("User").LastPageVisited =
context.Request.ServerVariables("PATH_INFO")
End If

There is no Shared Request property of HttpContext object...

"tshad" wrote:

> I am trying to build a small shared routine that I call in all my pages. I
> don't want to create an object reference as I just want to make a routine
> that I can use to add in code that needs to be executed at the beginning of
> all my pages with having to go change all the pages whenever this is needed.
>
> Here is the routine I am setting up:
> ************************************************** *********
> Imports System
> Imports System.Web
> Imports System.IO
> Imports System.Web.UI
> Imports System.Web.SessionState
> Imports System.Data
> Imports System.Data.SqlClient
> Imports System.Web.HttpCookie
> Imports System.Web.HttpCookieCollection
> Imports System.Web.HttpResponse
> Imports System.Web.HttpRequest
> imports System.Web.HttpContext
> Imports System.Web.HttpApplication
> Imports System.Web.HttpApplicationState
> Imports System.Collections
> Imports FtsData
>
> NameSpace MyFunctions
>
> Public Class PageLoad
>
> Public Shared sub InitialPageLoad ()
>
> HttpContext.Current.Session("User").LastPageVisite d =
> System.Web.HttpContext.Request.ServerVariables("PA TH_INFO")
>
> end sub
>
> End Class
> End Namespace
> ************************************************** **************************
> *******
>
> but I am getting an error on the System.Web.HttpContext.Request:
>
> C:\Inetpub\wwwroot\staffingworkshop\Classes\PageLo ad.vb(26) : error BC30469:
> Reference to a non-shared member requires an object reference.
>
> I just want to get the server variable Path_Info to get the current page.
>
> How can I do this without setting up an object reference?
>
> Thanks,
>
> Tom
>
>
>


tshad 01-09-2006 06:31 AM

Re: Shared and object References
 
"Sergey Poberezovskiy" <SergeyPoberezovskiy@discussions.microsoft.com> wrote
in message news:E1B119C6-1B2A-4B3E-97F1-071DAF1F56EA@microsoft.com...
> Try:
>
> Dim context As HttpContext = HttpContext.Current
> If Not context Is Nothing Then
> context .Session("User").LastPageVisited =
> context.Request.ServerVariables("PATH_INFO")
> End If
>
> There is no Shared Request property of HttpContext object...


Oh.

I thought it was compaining that my InitialPageLoad was shared and needed to
be an object.

But you're saying I just have to create an object context inside my shared
routine.

I'll try that.

Thanks,

Tom
>
> "tshad" wrote:
>
> > I am trying to build a small shared routine that I call in all my

pages. I
> > don't want to create an object reference as I just want to make a

routine
> > that I can use to add in code that needs to be executed at the beginning

of
> > all my pages with having to go change all the pages whenever this is

needed.
> >
> > Here is the routine I am setting up:
> > ************************************************** *********
> > Imports System
> > Imports System.Web
> > Imports System.IO
> > Imports System.Web.UI
> > Imports System.Web.SessionState
> > Imports System.Data
> > Imports System.Data.SqlClient
> > Imports System.Web.HttpCookie
> > Imports System.Web.HttpCookieCollection
> > Imports System.Web.HttpResponse
> > Imports System.Web.HttpRequest
> > imports System.Web.HttpContext
> > Imports System.Web.HttpApplication
> > Imports System.Web.HttpApplicationState
> > Imports System.Collections
> > Imports FtsData
> >
> > NameSpace MyFunctions
> >
> > Public Class PageLoad
> >
> > Public Shared sub InitialPageLoad ()
> >
> > HttpContext.Current.Session("User").LastPageVisite d =
> > System.Web.HttpContext.Request.ServerVariables("PA TH_INFO")
> >
> > end sub
> >
> > End Class
> > End Namespace
> >

************************************************** **************************
> > *******
> >
> > but I am getting an error on the System.Web.HttpContext.Request:
> >
> > C:\Inetpub\wwwroot\staffingworkshop\Classes\PageLo ad.vb(26) : error

BC30469:
> > Reference to a non-shared member requires an object reference.
> >
> > I just want to get the server variable Path_Info to get the current

page.
> >
> > How can I do this without setting up an object reference?
> >
> > Thanks,
> >
> > Tom
> >
> >
> >





All times are GMT. The time now is 10:18 AM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57