Click here to Skip to main content
15,885,767 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
-i create one public function in my cs page and i want to use that function in other page and global.asax so how to i use that function in other page?
Posted

Create an object of that class, say if u have function in page1, in page2 create object of page1 and use that object to invoke your function like obj.func();
 
Share this answer
 
Here is an example:
C#
Class obj = new Class();
obj.methodCall();
 
Share this answer
 
Why don't you create a common class, having all methods common placed there. Now on which page you want the method create an object of the class and access the method.
 
Share this answer
 
C#
public class Class1
{

    public void  display()
    {
        Console.WriteLine("Hello Guys");
    }
}

public class Class2
{
    Class1 obj = new Class1();
    public void get()
    {
        obj.display();
    }
    static void main()
    {
        Class1 ooo = new Class1();
        ooo.display();
    }
}

//here i have called the object of the class twice and invoked the function which is public
 
Share this answer
 
v2
Comments
Anuja Pawar Indore 28-Feb-12 2:17am    
Added code block
The Doer 28-Feb-12 4:18am    
how to add this code block?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900