473,322 Members | 1,431 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,322 software developers and data experts.

How to use the same function in more than one page

13
Hello all,

I m developing a web page in .Net using C# and many pages use the same functions I don't wont to write the same function in every page is there a way to write the function in one page and call it from all other pages as needed.

I am not sure if it is only by macking the function public or is there some other way
Feb 1 '07 #1
5 1192
You can do that
Simplest way is that create a class which will have all common function
make those function as static so need to create the object every time :)
Feb 1 '07 #2
hime
13
hi

Actually I don't know what should I use to be able to use the fun. in the new page and should I write the fun. in a web form page. again for using the class
should I use a code like this?

using pagename.classname;

and then I can call the fun. excuse me if the is not suppose to be asked??
Feb 1 '07 #3
No Yar
You are asking very basic questions Dude do one thing add new only .cs file
give a proper name to the class and write all functions as static
When you want to call these functions call from your page.cs file like
classname.functionname only Simple Dudde try to do much programming
Best Luck
Feb 1 '07 #4
hime
13
No Yar
You are asking very basic questions Dude do one thing add new only .cs file
give a proper name to the class and write all functions as static
When you want to call these functions call from your page.cs file like
classname.functionname only Simple Dudde try to do much programming
Best Luck

thanx dude ya got me i am nubbe at this ;-| am learning and programming at the same time so .... that is it .... thanx again
Feb 4 '07 #5
nmsreddi
366 256MB
Hello

This is nothing but the way of using some oops concepts.

If you want to use the same function in many form with out writing the code ,then just make a class what ever the functions you want to again ,just write all those functions in that class file .where ever you want to use that function ,just create an object of that class file (in which the function is located)
just use that object you can get all the functions in that class file

for example:

//lets class name be classmain in which all your functions exists

//let your form name be form1

where ever you want to use that functions just create object of class like this

classmain objclass=new classmain();

now you can use your objclass in your as many times as needed just by having a dot

objclass.

you will get all the public methods and variables of that class.

Hope you will get the best

Regards

Nmsreddi
Feb 5 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: Mary Catherine | last post by:
I have 2 scipts that I am trying to get to run on the same page. One is a time/date script, the other is a countdown script (i.e. countdown days, hours, mins until a given date). They both work...
6
by: Beat | last post by:
Is it possible to reference the same codebehind from 2 different pages? It would be an elegant solution, where we do need different settings at the PAGE-Level for 2 user-Groups but the rest of...
7
by: John | last post by:
Hi I have forgotten how to do this. Got a <form ... > with <input type="button" name="Hit Me" onclick="whatever()"> </form> The output of the Javascript function 'whatever' appears on...
3
by: tshad | last post by:
I have a page that I am getting a username and password as a random number (2 letters, one number and 4 more letters) I have 2 functions I call: *************************************************...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.