|
-
Sep 15th, 2006, 01:44 PM
#1
Thread Starter
Lively Member
[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?
-
Sep 15th, 2006, 03:16 PM
#2
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
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Sep 15th, 2006, 04:28 PM
#3
Thread Starter
Lively Member
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?
-
Sep 16th, 2006, 11:10 PM
#4
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?
-
Sep 17th, 2006, 11:29 PM
#5
Thread Starter
Lively Member
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.
-
Sep 18th, 2006, 05:13 PM
#6
Thread Starter
Lively Member
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|