Professional Web Applications Themes

Multiple Composite Control Instances - ASP.NET Building Controls

I'm developing a composite control and one of the things I've run into is how to support being able to put multiple instances of my control onto a web form. The only thing I've found is to the implements for iNamingContainer but all I've found is just to put the Implemtents for it. Nothing if I need to do anything else I've tried that and still nothing chnages. Do I need to handle the uniqie naming of items in my control myself? Anyone point to any good articles? Thanks...

  1. #1

    Default Multiple Composite Control Instances

    I'm developing a composite control and one of the things
    I've run into is how to support being able to put multiple
    instances of my control onto a web form. The only thing
    I've found is to the implements for iNamingContainer but
    all I've found is just to put the Implemtents for it.
    Nothing if I need to do anything else

    I've tried that and still nothing chnages. Do I need to
    handle the uniqie naming of items in my control myself?

    Anyone point to any good articles?

    Thanks
    Russ Guest

  2. #2

    Default Re: Multiple Composite Control Instances

    "Russ" <russell.lazarekey.com> wrote in message
    news:643601c37d47$5b9afda0$a601280aphx.gbl...
    > I'm developing a composite control and one of the things
    > I've run into is how to support being able to put multiple
    > instances of my control onto a web form. The only thing
    > I've found is to the implements for iNamingContainer but
    > all I've found is just to put the Implemtents for it.
    > Nothing if I need to do anything else
    >
    > I've tried that and still nothing chnages. Do I need to
    > handle the uniqie naming of items in my control myself?
    >
    > Anyone point to any good articles?
    A composite control must implement INamingContainer. INamingContainer is
    just a marker interface. There is no code for you to implement.
    --
    John Saunders
    Internet Engineer
    [email]john.saunderssurfcontrol.com[/email]


    John Saunders Guest

  3. #3

    Default Re: Multiple Composite Control Instances

    That's the same information I've read but what does that do? I've read
    that and placed that in but it doesn't seem to do anything.

    The problem I'm having is that the controls that are placed in the
    composite controls are assigned IDS when I add them to the control. I
    need to set the ID so I can reference in javascript. But when I do that
    and place 2 instacnes of the control onto my web form, I wind up with 2
    controls named the same for every control on my composite control.

    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Russ Lazarek Guest

  4. #4

    Default Re: Multiple Composite Control Instances

    "Russ Lazarek" <russell.lazarekey.com> wrote in message
    news:%234qwyzUfDHA.2152tk2msftngp13.phx.gbl...
    > That's the same information I've read but what does that do? I've read
    > that and placed that in but it doesn't seem to do anything.
    >
    > The problem I'm having is that the controls that are placed in the
    > composite controls are assigned IDS when I add them to the control. I
    > need to set the ID so I can reference in javascript. But when I do that
    > and place 2 instacnes of the control onto my web form, I wind up with 2
    > controls named the same for every control on my composite control.
    You should not set the ID. Instead, pass control.ClientID to JavaScript so
    that it knows what the changed ID is.
    --
    John Saunders
    Internet Engineer
    [email]john.saunderssurfcontrol.com[/email]


    John Saunders Guest

  5. #5

    Default Re: Multiple Composite Control Instances

    But if I don't assign an ID to the control when it is created, the
    control when rendered on the HTML page does not have any ID or name
    field. How does it get named? I'm creating controls in the composite
    both by DIMing them and adding them to the controls collection as well
    as creating them manually and writing out the tags to the writer in the
    render.


    As I totally missing something? Is there any example you know of that
    you can point me to.

    Thanks

    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Russ Lazarek Guest

  6. #6

    Default Re: Multiple Composite Control Instances

    "Russ Lazarek" <russell.lazarekey.com> wrote in message
    news:uyVkuEVfDHA.3216tk2msftngp13.phx.gbl...
    > But if I don't assign an ID to the control when it is created, the
    > control when rendered on the HTML page does not have any ID or name
    > field. How does it get named? I'm creating controls in the composite
    > both by DIMing them and adding them to the controls collection as well
    > as creating them manually and writing out the tags to the writer in the
    > render.
    >
    >
    > As I totally missing something? Is there any example you know of that
    > you can point me to.
    Yes, you are. :-)

    In CreateChildControls, when you create a child control, give it an
    appropriate ID, like "btnOk". When you add it to your Controls collection,
    the ClientID property will be changed to have a prefix, making in unique.
    Pass this ClientID to JavaScript instead of passing the ID.

    I'm sorry, but I don't have any VB.NET examples to show you. I will
    recommend my favorite book on controls, though:

    "Developing Microsoft® ASP.NET Server Controls and Components" from
    Microsoft Press, by Nikhil Kothari and Vandana Datye
    ([url]http://www.microsoft.com/mspress/books/5728.asp[/url]).
    --
    John Saunders
    Internet Engineer
    [email]john.saunderssurfcontrol.com[/email]



    John Saunders Guest

  7. #7

    Default Re: Multiple Composite Control Instances

    Thanks I actually have that book on order, just havn't gotten it yet.

    So basically it sounds like the way I'm creating controls in the render
    is totally wrong and instead I have to move everything to the
    createchild controls which I can do. One last question, in the render
    I'm currently attaching an event to an onclick event for an img tag, If
    I move that to createchildcontrol, how do I add that client side event
    to the control?

    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Russ Lazarek Guest

  8. #8

    Default Re: Multiple Composite Control Instances

    "Russ Lazarek" <russell.lazarekey.com> wrote in message
    news:OHu17aVfDHA.1888TK2MSFTNGP12.phx.gbl...
    > Thanks I actually have that book on order, just havn't gotten it yet.
    >
    > So basically it sounds like the way I'm creating controls in the render
    > is totally wrong and instead I have to move everything to the
    > createchild controls which I can do. One last question, in the render
    > I'm currently attaching an event to an onclick event for an img tag, If
    > I move that to createchildcontrol, how do I add that client side event
    > to the control?
    The exact same way you would in Render. control.Attributes["onclick"] =
    "script;return;"
    --
    John Saunders
    Internet Engineer
    [email]john.saunderssurfcontrol.com[/email]


    John Saunders Guest

  9. #9

    Default Re: Multiple Composite Control Instances

    Hi Russ,

    I am sorry if there is any misunderstanding.

    As I understand, your last question is

    How to associate Client-Side Events with Server-Side Controls

    Based on my research and experience, the following Knowledge Base article
    is useful to you.

    [url]http://support.microsoft.com/default.aspx?scid=kb;EN-US;318814[/url]

    Does it answer your question? If I have misunderstood your concern, please
    feel free to let me know.

    Best regards,

    Jacob Yang
    Microsoft Online Partner Support
    <MCSD>
    Get Secure! ¨C [url]www.microsoft.com/security[/url]
    This posting is provided "as is" with no warranties and confers no rights.

    Jacob Yang [MSFT] Guest

Similar Threads

  1. Replies: 0
    Last Post: February 1st, 09:01 PM
  2. Replies: 1
    Last Post: July 30th, 02:31 PM
  3. Replies: 2
    Last Post: July 22nd, 10:58 PM
  4. Multiple instances of a control? <img> ??
    By Kristoffer Arfvidson in forum ASP.NET Web Services
    Replies: 1
    Last Post: December 21st, 03:51 PM
  5. Replies: 2
    Last Post: July 2nd, 08:05 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not 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