I found some good articles, but nothing to pull everything together for me. To keep this simple, lets create a class to simply print "hello world" to a label on my page. My questions are:
1) I want to put the class code into an external file that I can reference and use on multiple pages. What do I need to do?
2) How can I have the class generate a string that is displayed on a label since I cant just say labelID.text=string?
thanks
You can do something like.
1public class DisplayString2{3public static void DispString(Label lbl,string str)4 {5 lbl.Text = str;6 }7}89// this is your call to that method from somewhere else.1011DisplayString.DispSpring(this.labelID,"Hello World");
Last time i tried that it worked.
narowgate:
I found some good articles, but nothing to pull everything together for me. To keep this simple, lets create a class to simply print "hello world" to a label on my page. My questions are:
1) I want to put the class code into an external file that I can reference and use on multiple pages. What do I need to do?
Hi,
That's called business object. Follow these steps:
1. Create .cs/.vb file where you should do something you want.
2. Compile the business object into a usable object. Then you will get *.dll in your project's bin\debug folder.
3. Add your new DLL via "Add Reference" when right click the Solution Explorer.
4. Finish. You can do your job.
narowgate:
2) How can I have the class generate a string that is displayed on a label since I cant just say labelID.text=string?
thanks
The reply above is right direction for you to follow. I hope that you should write your class with return a string or add get method. Then you can use get method to get string in the code-behind file.
Happy programming.
0 comments:
Post a Comment