473,413 Members | 1,696 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

Is it possible to share functions across aspx.vb pages?

Dan
We have some session variables that need to be reset to their default values
at certain times throughout the application. Rather than repeating the code
on each page that requires it, is there a way to hold this server-side code
some place and have each page call it when necessary? I can already see
another "shared function" that will be used similarly down the road, so is
there a way to put all these shared functions into one file?

In classic ASP we used the <!-- #INCLUDE FILE="sharedfunctions.asp" -->
directive. Is there something similar in ASP.Net?

Thanks in advance,
Dan
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.556 / Virus Database: 348 - Release Date: 12/26/2003
Nov 18 '05 #1
7 3589
just cast it, IIRC

((yourPageClass)this.page).functionName
--
Curt Christianson
Owner/Lead Developer, DF-Software
www.Darkfalz.com
"Dan" <dh******@somewhere.com> wrote in message
news:Ot**************@TK2MSFTNGP11.phx.gbl...
We have some session variables that need to be reset to their default values at certain times throughout the application. Rather than repeating the code on each page that requires it, is there a way to hold this server-side code some place and have each page call it when necessary? I can already see
another "shared function" that will be used similarly down the road, so is
there a way to put all these shared functions into one file?

In classic ASP we used the <!-- #INCLUDE FILE="sharedfunctions.asp" -->
directive. Is there something similar in ASP.Net?

Thanks in advance,
Dan
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.556 / Virus Database: 348 - Release Date: 12/26/2003

Nov 18 '05 #2
Dan
hmmm...I kind of understand what you are saying and think it will work.

A couple of questions though

Does "yourPageClass" have to be another aspx.vb file? I only ask because
the corresponding aspx file would never be used.

Also, in the called function, would the submitted request.form data be
available?

Finally....what does IIRC mean?

Thanks,
Dan
"Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
just cast it, IIRC

((yourPageClass)this.page).functionName
--
Curt Christianson
Owner/Lead Developer, DF-Software
www.Darkfalz.com
"Dan" <dh******@somewhere.com> wrote in message
news:Ot**************@TK2MSFTNGP11.phx.gbl...
We have some session variables that need to be reset to their default

values
at certain times throughout the application. Rather than repeating the

code
on each page that requires it, is there a way to hold this server-side

code
some place and have each page call it when necessary? I can already see
another "shared function" that will be used similarly down the road, so is there a way to put all these shared functions into one file?

In classic ASP we used the <!-- #INCLUDE FILE="sharedfunctions.asp" -->
directive. Is there something similar in ASP.Net?

Thanks in advance,
Dan
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.556 / Virus Database: 348 - Release Date: 12/26/2003


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.556 / Virus Database: 348 - Release Date: 12/26/2003
Nov 18 '05 #3
1) the yourPageClass is the name of the class in your codebehind (.vb) file.

2) the same info should be available.

3) IIRC = If I Remember Correctly (www.acronymfinder.com)
--
Curt Christianson
Owner/Lead Developer, DF-Software
www.Darkfalz.com
"Dan" <dh******@somewhere.com> wrote in message
news:eo**************@TK2MSFTNGP11.phx.gbl...
hmmm...I kind of understand what you are saying and think it will work.

A couple of questions though

Does "yourPageClass" have to be another aspx.vb file? I only ask because
the corresponding aspx file would never be used.

Also, in the called function, would the submitted request.form data be
available?

Finally....what does IIRC mean?

Thanks,
Dan
"Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
just cast it, IIRC

((yourPageClass)this.page).functionName
--
Curt Christianson
Owner/Lead Developer, DF-Software
www.Darkfalz.com
"Dan" <dh******@somewhere.com> wrote in message
news:Ot**************@TK2MSFTNGP11.phx.gbl...
We have some session variables that need to be reset to their default values
at certain times throughout the application. Rather than repeating the
code
on each page that requires it, is there a way to hold this server-side

code
some place and have each page call it when necessary? I can already
see another "shared function" that will be used similarly down the road, so is there a way to put all these shared functions into one file?

In classic ASP we used the <!-- #INCLUDE

FILE="sharedfunctions.asp" --> directive. Is there something similar in ASP.Net?

Thanks in advance,
Dan
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.556 / Virus Database: 348 - Release Date: 12/26/2003


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.556 / Virus Database: 348 - Release Date: 12/26/2003

Nov 18 '05 #4
You could create a class, which can do this. If you're using Visual Studio
..NET, do the following:

Right Click on the project, and choose Add -> Add Class. In the filename
box, type "Global.vb". The code in the class should look something like
this:
Namespace YourProjectNamespace
Class Global

Public Shared Sub ResetSessionVariables()
With System.Web.HttpContext.Current
.Item("MyFirstSessionVar") = String.Empty
.Item("MySecondSessionVar") = String.Empty
.Item("MyThirdSessionVar") = String.Empty
End With
End Sub
'You can add more shared functions here
End Class
End Namespace
You can then call this code from any of your ASPX pages, using
Global.ResetSessionVariables()

Hope this helps,

Mun


"Dan" <dh******@somewhere.com> wrote in message
news:Ot**************@TK2MSFTNGP11.phx.gbl...
We have some session variables that need to be reset to their default values at certain times throughout the application. Rather than repeating the code on each page that requires it, is there a way to hold this server-side code some place and have each page call it when necessary? I can already see
another "shared function" that will be used similarly down the road, so is
there a way to put all these shared functions into one file?

In classic ASP we used the <!-- #INCLUDE FILE="sharedfunctions.asp" -->
directive. Is there something similar in ASP.Net?

Thanks in advance,
Dan
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.556 / Virus Database: 348 - Release Date: 12/26/2003


Nov 18 '05 #5
Istead of going through the head of calling you page class from other
pages...
just create a new class which have all the common functions...

create instance of that class wherever needed and use your funcitons...

hope that helps.....

--
Regards,

HD

"Dan" <dh******@somewhere.com> wrote in message
news:Ot**************@TK2MSFTNGP11.phx.gbl...
We have some session variables that need to be reset to their default values at certain times throughout the application. Rather than repeating the code on each page that requires it, is there a way to hold this server-side code some place and have each page call it when necessary? I can already see
another "shared function" that will be used similarly down the road, so is
there a way to put all these shared functions into one file?

In classic ASP we used the <!-- #INCLUDE FILE="sharedfunctions.asp" -->
directive. Is there something similar in ASP.Net?

Thanks in advance,
Dan
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.556 / Virus Database: 348 - Release Date: 12/26/2003

Nov 18 '05 #6
Dan
Thanks.
"Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
news:Oe**************@TK2MSFTNGP12.phx.gbl...
1) the yourPageClass is the name of the class in your codebehind (.vb) file.
2) the same info should be available.

3) IIRC = If I Remember Correctly (www.acronymfinder.com)
--
Curt Christianson
Owner/Lead Developer, DF-Software
www.Darkfalz.com
"Dan" <dh******@somewhere.com> wrote in message
news:eo**************@TK2MSFTNGP11.phx.gbl...
hmmm...I kind of understand what you are saying and think it will work.

A couple of questions though

Does "yourPageClass" have to be another aspx.vb file? I only ask because
the corresponding aspx file would never be used.

Also, in the called function, would the submitted request.form data be
available?

Finally....what does IIRC mean?

Thanks,
Dan
"Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
just cast it, IIRC

((yourPageClass)this.page).functionName
--
Curt Christianson
Owner/Lead Developer, DF-Software
www.Darkfalz.com
"Dan" <dh******@somewhere.com> wrote in message
news:Ot**************@TK2MSFTNGP11.phx.gbl...
> We have some session variables that need to be reset to their default values
> at certain times throughout the application. Rather than repeating

the code
> on each page that requires it, is there a way to hold this server-side code
> some place and have each page call it when necessary? I can already see > another "shared function" that will be used similarly down the road, so
is
> there a way to put all these shared functions into one file?
>
> In classic ASP we used the <!-- #INCLUDE

FILE="sharedfunctions.asp" --> > directive. Is there something similar in ASP.Net?
>
> Thanks in advance,
> Dan
>
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.556 / Virus Database: 348 - Release Date: 12/26/2003
>
>

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.556 / Virus Database: 348 - Release Date: 12/26/2003


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.556 / Virus Database: 348 - Release Date: 12/26/2003
Nov 18 '05 #7
Dan
There we go, that's what I was looking for.

Thanks,
Dan

"Munsifali Rashid" <mun.news@#RemoveToReply#cordlessmouse.co.uk> wrote in
message news:%2****************@tk2msftngp13.phx.gbl...
You could create a class, which can do this. If you're using Visual Studio .NET, do the following:

Right Click on the project, and choose Add -> Add Class. In the filename
box, type "Global.vb". The code in the class should look something like
this:
Namespace YourProjectNamespace
Class Global

Public Shared Sub ResetSessionVariables()
With System.Web.HttpContext.Current
.Item("MyFirstSessionVar") = String.Empty
.Item("MySecondSessionVar") = String.Empty
.Item("MyThirdSessionVar") = String.Empty
End With
End Sub
'You can add more shared functions here
End Class
End Namespace
You can then call this code from any of your ASPX pages, using
Global.ResetSessionVariables()

Hope this helps,

Mun


"Dan" <dh******@somewhere.com> wrote in message
news:Ot**************@TK2MSFTNGP11.phx.gbl...
We have some session variables that need to be reset to their default

values
at certain times throughout the application. Rather than repeating the

code
on each page that requires it, is there a way to hold this server-side

code
some place and have each page call it when necessary? I can already see
another "shared function" that will be used similarly down the road, so is there a way to put all these shared functions into one file?

In classic ASP we used the <!-- #INCLUDE FILE="sharedfunctions.asp" -->
directive. Is there something similar in ASP.Net?

Thanks in advance,
Dan
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.556 / Virus Database: 348 - Release Date: 12/26/2003


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.556 / Virus Database: 348 - Release Date: 12/26/2003
Nov 18 '05 #8

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

Similar topics

3
by: Nikki | last post by:
Hi, I would like to create a central storage place for javascript functions that I can then access from any of my asp.net projects. An example of what I need it for is as follows: I have a...
1
by: Steve - DND | last post by:
Is it possible to get my ASPX pages to compile in a namespace different than ASP? Why don't ASPX pages compile by default in the namespace of their code-behind? This causes me to have to import...
1
by: Eric | last post by:
Hello, I am trying to come up with the best way to pass large amounts of data from page to page, namely a data table. The user needs to enter data into a form in one page and confirm it on...
6
by: Victor Hadianto | last post by:
Hi All, I'm a beginner with ASP.Net so please bear with me. I'm having difficulties trying to understand the behaviour of static variable across multiple ASP.Net page. My static variable is a...
3
by: Wayne Wengert | last post by:
I want to use some javascript functions in aspx pages but I cannot find the correct way to call/link to them. When I search NGs or Google, the examples are mostly for asp pages. Does anyone have a...
6
by: antonyliu2002 | last post by:
I am using ASP.NET 1.1. In my web application, multiple pages will be using the same functions. I am wondering if I can just pick out the shared code and save it in a separate file and then...
0
by: Mike Dee | last post by:
I'm new to index server and can't get any DocTitle value back from index server (it is returned as null) for all my aspx pages. It do get the values from inside the <title> tags from my static...
5
by: Gordowey | last post by:
Hi all, I would like to know if is possible to rename my aspx .pages to .html (or to a different extension..for example .mjk)..and continue running the code behind, everything......as normal...
3
by: Aryan | last post by:
Hi, I have problem in creating Partial Class for ASPX pages. As my Codebase file for ASPX page is having more then 2500 lines of code. So its very hard to maintain the code. So I wanted to know,...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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...

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.