I haven't tried this exact idea, but I think there is an explanation for this in this article: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvs05/html /migratefromaspnetto2.asp
I had a similar issue, and it was pretty tricky to work out. In our case, we had a set of controls in a sub-project that needed to have some shared code. The solution was worked out well in this post: http://discuss.develop.com/archives/wa.exe?A2=ind0512A&L=DOTNET-WEB&D=0&H=0& I=-3&O=T&T=0&P=1959. You might take a look to see if this would point you in the right direction. Ryan -----Original Message----- From: Discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] On Behalf Of Jon Rothlander Sent: Monday, January 16, 2006 9:55 PM To: [email protected] Subject: [ADVANCED-DOTNET] Interacting with ASPX controls from a class called by the code-behind class... I have an ASPX page and I need to interact with the controls on this page from another class that is not my code-behind class. I cannot figure out how to do this without creating a property to read when the class returns from the code-behind class. What I would like to know is how I can reference the controls on the ASPX page in this 2nd class but without having to create properties. ASPX Page \ Code Behind Class \ \ Class1 Class2 The code behind class might have code that looks this... dim c1 as new class1 dim c2 as new class2 if bl then c1.execute() else c2.execute() end if The class code might look something like this... Class1 public function execute() Textbox1.Visible = True Textbox2.Visible = True Textbox3.Visible = False Textbox4.Visible = False end function Class2 public function execute() Textbox1.Visible = False Textbox2.Visible = False Textbox3.Visible = True Textbox4.Visible = True end function What is unique is that I cannot easily move the functions in class1 and class2 into the code-behind class. So I am trying to figure out if I can do something to give this sub-class access to the controls code-behind class. I know that I can modify the declarations of the controls from "protected" to "public" to gain access, but how to I reference them in the sub-class if I do this? If I cannot do this, the only option that I can see is to merge the code-behind class and the sub-class. I can do that, but it will be a significantly painfully process. I am trying to avoid this if I can. Any suggestions, ideas, samples, references, links, etc. would be very much appreciated. It seems like this would be a simple matter of having the sub-class inherit the code-behind class, but I cannot see the answer or figure out how to set up the code. Best regards, Jon =================================== This list is hosted by DevelopMentor. http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com
