Results 1 to 6 of 6

Thread: [RESOLVED] [2.0] Accessing user control's elements

  1. #1

    Thread Starter
    Lively Member {yak}'s Avatar
    Join Date
    Aug 2005
    Posts
    119

    Resolved [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?
    {yak}

  2. #2
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    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

  3. #3

    Thread Starter
    Lively Member {yak}'s Avatar
    Join Date
    Aug 2005
    Posts
    119

    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?
    {yak}

  4. #4
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    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?

  5. #5

    Thread Starter
    Lively Member {yak}'s Avatar
    Join Date
    Aug 2005
    Posts
    119

    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.
    {yak}

  6. #6

    Thread Starter
    Lively Member {yak}'s Avatar
    Join Date
    Aug 2005
    Posts
    119

    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
    {yak}

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width