PC Review


Reply
Thread Tools Rate Thread

Can context file reference a sub that's iin the .master or is there such a thing as a module

 
 
_Who
Guest
Posts: n/a
 
      2nd Sep 2008
I have a sub that I need to use in the .master and the context aspx.vb
files.

How can I do that without reproducing it in each of those files.

Can I reference it if it is in the .master or is there such a thing as a
module?

I can't find any documentation on how to do this.

Thanks


 
Reply With Quote
 
 
 
 
_Who
Guest
Posts: n/a
 
      3rd Sep 2008
Even though I mentioned master in my post, I was focused on looking for a
module-like approach.

I found out about App_Code and created a class file in it containing the
sub.

I had just noticed that a reference to Session in the sub code produced an
error when I received your post.

I changed to the method you pointed to (using master.mysub) and that works
well.

For future reference: Do you know why I received an error when the sub
referenced Session (Session is not declared)?

If I got rid of that error do you think that approach would have worked?

A related question - there is any reason asp.net not to use Shared if a sub
does not access an instance variable?



Thanks a lot


"Mark Rae [MVP]" <(E-Mail Removed)> wrote in message
news:elZm%(E-Mail Removed)...
> "_Who" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>
>> I can't find any documentation on how to do this.

>
> GIYF:
> http://www.google.co.uk/search?sourc...tion+reference
>
>
> --
> Mark Rae
> ASP.NET MVP
> http://www.markrae.net



 
Reply With Quote
 
_Who
Guest
Posts: n/a
 
      3rd Sep 2008
The Error from "Session" was because of the use of "Shared"
Guess all subs in App_Code are implicitly Shared.


"Mark Rae [MVP]" <(E-Mail Removed)> wrote in message
news:elZm%(E-Mail Removed)...
> "_Who" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>
>> I can't find any documentation on how to do this.

>
> GIYF:
> http://www.google.co.uk/search?sourc...tion+reference
>
>
> --
> Mark Rae
> ASP.NET MVP
> http://www.markrae.net



 
Reply With Quote
 
_Who
Guest
Posts: n/a
 
      3rd Sep 2008

"Mark Rae [MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "_Who" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>
> [please don't top-post]
>
>>>> I can't find any documentation on how to do this.
>>>
>>> GIYF:
>>> http://www.google.co.uk/search?sourc...tion+reference

>>
>> For future reference: Do you know why I received an error when the sub
>> referenced Session (Session is not declared)?

>
> Session needs a current HttpContext - HttpContext.Current.Session["....."]


Thanks, I made a note in the code for next time.

>
>> If I got rid of that error do you think that approach would have worked?

>
> Probably...
>
>
> --
> Mark Rae
> ASP.NET MVP
> http://www.markrae.net



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How show a master page reference an image file? AAaron123 Microsoft ASP .NET 15 25th Nov 2008 05:52 PM
Context.RewritePath and master pages Keef Microsoft C# .NET 1 14th Oct 2008 08:07 AM
How to get User Context in Master Pages Matt Microsoft ASP .NET 1 25th Sep 2006 08:56 PM
ASPNET2: Master Page File Reference Problem Mark Olbert Microsoft ASP .NET 3 4th Feb 2006 05:31 PM
ASP.NET 2.0: master pages and web user controls: reference to a non-shared member requires an object reference bminder Microsoft ASP .NET 0 24th Jun 2005 01:22 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:30 PM.