Custom control is naming it's components differently

  • Thread starter Nathan Sokalski
  • Start date
N

Nathan Sokalski

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.
 
R

Riki

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.
 
N

Nathan Sokalski

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.
 
P

Peter Zolja

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top