arunlal a

arunlal a

  • 1.7k
  • 49
  • 19.2k

How to create an Instance of a class ??

Jul 3 2006 12:05 AM
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

Answers (2)

0
arunlal a

arunlal a

  • 1.7k
  • 49
  • 19.2k
Jul 4 2006 12:02 AM
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
Edward Legaspi

Edward Legaspi

  • 0
  • 3
  • 0
Jul 3 2006 2:23 AM
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