Skip to content

How to create an Instance of a class ??

arunlal a

Asked Jul 2, 2006, 8:05 PM EDT2 answers
Share
LinkedInX
In VS2005 webapplications how can we create an instance of a class in a page (Eg :deafult3.aspx) from another page (deafult2.aspx).In the earliar VS2003 we could create an instace of a page

Eg for page . Webapplication2.aspx

Webapplication2 objpage=new Webapplication2();

but here in VS2005 we can't create like this.

OR

How can we Import a page from another page in VS 2005 ,c#.

how it s possible ???

Hope u respond sooon.

thanks
Arunlal

2 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    Just make the class public and should reside in the same project directory. Class instance declaration is the same as it is from the .net2003.

    MyClass myClass = new MyClass(parameters).

    Or if the class resides on another project add a reference to that project first
    0
  • 0
    Yes i tried the same procedure ... but iam not getting the public class "myclass" on the other page .

    source code
    -----------
    page1.aspx
    ------------
    Public class myclass
    {

    public string test()
    {
    return "test return";
    }
    }

    Page2.aspx
    ----------
    in the code behind iam not getting the class "myclass" for creating instance of the class.

    hope u respond soon.
    0