[RESOLVED] [2.0] Accessing user control's elements
I have a page that loads in a few usercontrols into a datagrid. Each control has it's own values etc.
What I was wondering, if from the parent page, can I somehow access the values in those usercontrols?
Example of what I mean, say I load in 2 usercontrols, uc1 will have first name and last name and uc2 will have the same, but with different values, from the page that loads
in the usercontrol, can I somehow get first name and last name from each control?
Sorry if that doesn't make sense...kind of hard to explain(I can try to clarify if need be). Any ideas?
Re: [2.0] Accessing user control's elements
Make properties in the UserControl that return those values, mark the properties public so you can have access from another project or application
Re: [2.0] Accessing user control's elements
Sure, I left out a few details, sorry. That was my plan, problem is...the usercontrols are in a subfolder with a different namspace.
I thought, sure enough, access it like so: namespace.subnamespace.class
With no avail, although within the usercontrols class...namespace.subnamespace.class works. I thought all namespaces were public therefore I could access them that way?
Re: [2.0] Accessing user control's elements
If you have an instance variable what's stopping you accessing the members of the instance normally?
Re: [2.0] Accessing user control's elements
The usercontrol is loaded into a datalist(which is loaded when the edit button in the datagrid is clicked). So it does something like...
Code:
DataList dt = (DataList)e.Item.FindControl("dlname");
dt.ItemTemplate = Page.LoadTemplate("path");
So, I'm not quite sure how to get an instance?
Thanks for the replies thus far, greatly appreciated. :)
Re: [2.0] Accessing user control's elements
Ok, I think i've got it with nested FindControl(). I needed to start at the parent and work my way down.
Thanks for the input :)