Ask a Question related to ASP.NET Building Controls, Design and Development.

  1. #1

    Default control ID's

    Hi,

    My web page loads the controls dynamically using
    Page.LoadControl("~/myControls/myControl.ascx")

    The control myControl.ascx contains several controls with following ID's :
    "_content1", "_content2", "_content3", ...

    Once the control myControl.ascx has been loaded into the web page, the ID's
    have been changed : "_ctl0:_content1", "_ctl1:_content2", ...
    and the method Page.FindControl("_control1") returns nothing !

    Does anybody know how I can continu to use the Page.FindControl method ?

    Jill



    Jill Graham Guest

  2. Similar Questions and Discussions

    1. Loop and ID's
      Hi, I'm trying to reference the row ID using a loop and query. I was thinking some thing like this would work (although it doesn't) <cfquery...
    2. Getting a list of ID's from Selected Rows
      What I am trying to do is gets a list of the attribute ID's for each selected row. What I was wondering was if there was a way to loop through the...
    3. Is there any value in ID's Wildcard S&R ?
      I can think of no scenerio in which a wildcard search should not return the initial value of the searched character. As it works now, a wildcard S&R...
    4. Windows Event ID's
      Wondering if anyone has a list of all the event ID's for the Security and System Logs. Chris
    5. display COM+ process id's in an asp page
      Making a good old fashioned asp page and need to be able to display the IIS COM+ process id's (i.e. those that show up when attaching to a process...
  3. #2

    Default Re: control ID's

    Try setting the parent control's (myControl) id in the containing page.

    Example:
    mc = Page.LoadControl("~/myControls/myControl.ascx")
    mc.ID = "MyControl1"

    If you place the mc into a someother control (ie. PlaceHolder), then you
    will need to take that into account when building a path to it and its
    children.

    ccallen

    "Jill Graham" <jills_graham@yahoo.com.au> wrote in message
    news:emLuDXfLEHA.2456@TK2MSFTNGP12.phx.gbl...
    > Hi,
    >
    > My web page loads the controls dynamically using
    > Page.LoadControl("~/myControls/myControl.ascx")
    >
    > The control myControl.ascx contains several controls with following ID's :
    > "_content1", "_content2", "_content3", ...
    >
    > Once the control myControl.ascx has been loaded into the web page, the
    ID's
    > have been changed : "_ctl0:_content1", "_ctl1:_content2", ...
    > and the method Page.FindControl("_control1") returns nothing !
    >
    > Does anybody know how I can continu to use the Page.FindControl method ?
    >
    > Jill
    >
    >
    >

    ccallen Guest

  4. #3

    Default Re: control ID's

    You actually need add public properties (or methods) to you control to
    access the values in the embedded controls.

    Fred

    "ccallen" <ccallen@windowpane.com> wrote in message
    news:er5VgwfLEHA.2716@tk2msftngp13.phx.gbl...
    > Try setting the parent control's (myControl) id in the containing page.
    >
    > Example:
    > mc = Page.LoadControl("~/myControls/myControl.ascx")
    > mc.ID = "MyControl1"
    >
    > If you place the mc into a someother control (ie. PlaceHolder), then you
    > will need to take that into account when building a path to it and its
    > children.
    >
    > ccallen
    >
    > "Jill Graham" <jills_graham@yahoo.com.au> wrote in message
    > news:emLuDXfLEHA.2456@TK2MSFTNGP12.phx.gbl...
    > > Hi,
    > >
    > > My web page loads the controls dynamically using
    > > Page.LoadControl("~/myControls/myControl.ascx")
    > >
    > > The control myControl.ascx contains several controls with following ID's
    :
    > > "_content1", "_content2", "_content3", ...
    > >
    > > Once the control myControl.ascx has been loaded into the web page, the
    > ID's
    > > have been changed : "_ctl0:_content1", "_ctl1:_content2", ...
    > > and the method Page.FindControl("_control1") returns nothing !
    > >
    > > Does anybody know how I can continu to use the Page.FindControl method ?
    > >
    > > Jill
    > >
    > >
    > >
    >
    >

    Fred Hirschfeld Guest

  5. #4

    Default Re: control ID's

    Hi Jill,

    If you're looking for a child control of your usercontrol, and you're
    starting the search at the page, you'll need to do:
    [C#]
    FindControl ("YourUserControlID:YourChildID");

    Note the ':' syntax to help the FindControl method in finding your control.

    Let me know if this is what you're after or not,

    --
    Victor Garcia Aprea
    Microsoft MVP | ASP.NET
    Looking for insights on ASP.NET? Read my blog:
    [url]http://obies.com/vga/blog.aspx[/url]
    To contact me remove 'NOSPAM'. Please post all questions to the newsgroup

    "Jill Graham" <jills_graham@yahoo.com.au> wrote in message
    news:emLuDXfLEHA.2456@TK2MSFTNGP12.phx.gbl...
    > Hi,
    >
    > My web page loads the controls dynamically using
    > Page.LoadControl("~/myControls/myControl.ascx")
    >
    > The control myControl.ascx contains several controls with following ID's :
    > "_content1", "_content2", "_content3", ...
    >
    > Once the control myControl.ascx has been loaded into the web page, the
    ID's
    > have been changed : "_ctl0:_content1", "_ctl1:_content2", ...
    > and the method Page.FindControl("_control1") returns nothing !
    >
    > Does anybody know how I can continu to use the Page.FindControl method ?
    >
    > Jill
    >
    >
    >

    Victor Garcia Aprea [MVP] Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139