473,468 Members | 1,352 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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

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
Sep 2 '08 #1
5 935
"_Who" <Ca**********@roadrunner.comwrote in message
news:uo**************@TK2MSFTNGP02.phx.gbl...
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

Sep 2 '08 #2
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]" <ma**@markNOSPAMrae.netwrote in message
news:el****************@TK2MSFTNGP05.phx.gbl...
"_Who" <Ca**********@roadrunner.comwrote in message
news:uo**************@TK2MSFTNGP02.phx.gbl...
>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

Sep 3 '08 #3
"_Who" <Ca**********@roadrunner.comwrote in message
news:ue**************@TK2MSFTNGP04.phx.gbl...

[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["....."]
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

Sep 3 '08 #4
The Error from "Session" was because of the use of "Shared"
Guess all subs in App_Code are implicitly Shared.
"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:el****************@TK2MSFTNGP05.phx.gbl...
"_Who" <Ca**********@roadrunner.comwrote in message
news:uo**************@TK2MSFTNGP02.phx.gbl...
>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

Sep 3 '08 #5

"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:uV**************@TK2MSFTNGP03.phx.gbl...
"_Who" <Ca**********@roadrunner.comwrote in message
news:ue**************@TK2MSFTNGP04.phx.gbl...

[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

Sep 3 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Kenneth McDonald | last post by:
I'd like to propose a new PEP , for a standard library module that deals with files and file paths in an object oriented manner. I believe this module should be included as part of the standard...
3
by: Michael | last post by:
Hi, I am getting a strange error. Last night when I left work this was working perfectly. This morning when I try to run this code in VS2005, it comes up with an error saying "The name 'UserName'...
8
by: rn5a | last post by:
I have a user control named Enter.ascx which has 2 TextBoxes. The 2 TextBoxes are named txt1 & txt2. The entire logic of this user control (like the properties of the 2 TextBoxes using set/get...
1
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.