Last post May 28, 2012 05:03 PM by vahid bakkhi
May 28, 2012 04:03 PM|vahid bakkhi|LINK
i create a folder called Class and create a class into it called Class1
now i how to create a instance of the class in default page
please help me how to it do
May 28, 2012 04:14 PM|donpisci|LINK
Is it in the same namespace?
May 28, 2012 04:29 PM|vahid bakkhi|LINK
thanks for your answer
i create a namespace called myClass
May 28, 2012 04:37 PM|donpisci|LINK
No worries- did it help?
May 28, 2012 04:39 PM|vahid bakkhi|LINK
when i want using namespace
May 28, 2012 04:53 PM|donpisci|LINK
Make sure the class isn't marked private (by default it is, so add the word 'public' to the class declaration; i.e public class Class1).
If that doesn't work, then this might be a quick of Visual Studio; in your default page (the code behind), type
Class1 c = new Class1();
This will probably have the req lines underneath, but if you hover over the type name (Class1), you should get an option to 'generate a class for Class1'. Select this and the class will be created in the root folder. then, simply drag the Class1.cs file
into your desired folder.
Like I said, this is just a quirk of visual studio- you should just be able to create a class in your folder and then, providing the class isn't private, access it using the code above.
May 28, 2012 05:03 PM|vahid bakkhi|LINK
i check it ,it's public
and i try drag on page :
and i when write Class2 obj=new Class2();
but vs generate it in App_code folder
but i want create in my folder