Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reference Page control from custom class

Status
Not open for further replies.

bitseeker

Programmer
Nov 27, 2005
60
US
In ASP.NET 2.0, is there a way to reference a page control from a business object method, for example by accessing a "Pages" collection and use a construct like the below to access an individual page, control, and property?

Imports SomeNameSpaceFor.PagesCollection
Class TestClass
Sub TestSub
PagesCollection("NameOfTargetPage").NameOfTargetControl.NameOfControlProperty = whatevervalue
End Sub
End Class

Or could this be done by referencing the page by it's class name?

A page event would have initiated the object's method, so the page would be "live". I'd like to do this in a way that doesn't involve passing the control to the method through a method variable.

If not the above approach, is there a different way to reference a page control from a business object method?

For instance, is possible to pass the entire set of controls to the custom object for one page, and then specify an item in that collection?

Thanks!
 
I don't think it's possible and I don't think you are looking at it from thw right angle. The class that you have created cannot exist unless called from a page and therefore it shouldn't specifically target individual pages. You say that you don't want to pass the relevant controls into the class, but I think that's what should be done. You don't have to pass the controls individually if you don't want to and in fact you can pass the whole Pgae to the class.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Thanks for your response. Since I'm very new at this, there's a very good chance it's not the right approach. But, that's part of the price of learning :)

What's the specific syntax for passing a page to a custom class? Could you provide a brief example?

Thanks!
 
Ah, I think I figured out that last question:

Call SomeRoutine(Me)

from within the page.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top