Custom control is naming it's components differently

Discussion in 'ASP .Net Web Controls' started by Nathan Sokalski, Jan 4, 2007.

  1. I have written a custom control that uses AJAX (it implements
    IPostBackDataHandler and ICallbackEventHandler). I have tested it, and it
    seems to work the way I want. However, when I used it in another application
    of mine it named the components as ControlID$ComponentID instead of
    ControlID:ComponentID. I did not change any of the code, so obviously
    something else is making this happen. I need to have it name the components
    using ControlID:ComponentID so that my code works. What might be causing
    this different naming method? Thanks.
    --
    Nathan Sokalski

    http://www.nathansokalski.com/
    Nathan Sokalski, Jan 4, 2007
    #1
    1. Advertising

  2. Nathan Sokalski

    Riki Guest

    I don't know the cause of your problem, but I suggest that you don't try to
    predict the ID's of your controls, since the naming system may change in
    future versions of ASP.NET.

    Instead, use MyControl.ClientID to get the real ID of your controls.

    --

    Riki

    "Nathan Sokalski" <> wrote in message
    news:...
    >I have written a custom control that uses AJAX (it implements
    >IPostBackDataHandler and ICallbackEventHandler). I have tested it, and it
    >seems to work the way I want. However, when I used it in another
    >application of mine it named the components as ControlID$ComponentID
    >instead of ControlID:ComponentID. I did not change any of the code, so
    >obviously something else is making this happen. I need to have it name the
    >components using ControlID:ComponentID so that my code works. What might be
    >causing this different naming method? Thanks.
    > --
    > Nathan Sokalski
    >
    > http://www.nathansokalski.com/
    >
    Riki, Jan 4, 2007
    #2
    1. Advertising

  3. That would work, except for one small problem: I'm not talking about the id.
    When using AJAX, the IPostBackDataHandler interface is implemented, which
    contains a function called LoadPostData. This function has parameters called
    postDataKey and postCollection. To access the values of the different
    components, you use postCollection(postDataKey & "$ddlYear"). The expression
    postDataKey & "$ddlYear" evaluates to the client name, not the client id. I
    do not know of a property or function that returns the client name, so this
    is the only method I know of to get the component values, and it is also how
    I have seen it done by other people. Any ideas? Thanks.
    --
    Nathan Sokalski

    http://www.nathansokalski.com/

    "Riki" <> wrote in message
    news:O1HJvr%...
    >I don't know the cause of your problem, but I suggest that you don't try to
    >predict the ID's of your controls, since the naming system may change in
    >future versions of ASP.NET.
    >
    > Instead, use MyControl.ClientID to get the real ID of your controls.
    >
    > --
    >
    > Riki
    >
    > "Nathan Sokalski" <> wrote in message
    > news:...
    >>I have written a custom control that uses AJAX (it implements
    >>IPostBackDataHandler and ICallbackEventHandler). I have tested it, and it
    >>seems to work the way I want. However, when I used it in another
    >>application of mine it named the components as ControlID$ComponentID
    >>instead of ControlID:ComponentID. I did not change any of the code, so
    >>obviously something else is making this happen. I need to have it name the
    >>components using ControlID:ComponentID so that my code works. What might
    >>be causing this different naming method? Thanks.
    >> --
    >> Nathan Sokalski
    >>
    >> http://www.nathansokalski.com/
    >>

    >
    >
    Nathan Sokalski, Jan 4, 2007
    #3
  4. Nathan Sokalski

    Peter Zolja Guest

    > postDataKey & "$ddlYear" evaluates to the client name, not the client id.
    > I do not know of a property or function that returns the client name, so
    > this


    UniqueID
    Peter Zolja, Jan 19, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris Fulstow

    Naming data access components

    Chris Fulstow, Apr 12, 2006, in forum: ASP .Net
    Replies:
    6
    Views:
    443
    dkode
    Apr 14, 2006
  2. Harman
    Replies:
    1
    Views:
    2,494
    Moiristo
    Jul 28, 2006
  3. Torsten Landschoff
    Replies:
    8
    Views:
    973
    Torsten Landschoff
    Feb 22, 2007
  4. Nathan Sokalski
    Replies:
    3
    Views:
    303
    Peter Zolja
    Jan 19, 2007
  5. Nathan Sokalski

    Custom control is naming it's components differently

    Nathan Sokalski, Jan 4, 2007, in forum: ASP .Net Building Controls
    Replies:
    3
    Views:
    101
    Peter Zolja
    Jan 19, 2007
Loading...

Share This Page