Creating controls in ASP with dynamic IDs
Posted
by mattdell
on Stack Overflow
See other posts from Stack Overflow
or by mattdell
Published on 2010-05-06T19:17:38Z
Indexed on
2010/05/06
19:58 UTC
Read the original article
Hit count: 234
Hi, I'm creating a chat widget that will be dropped into CommunityServer. The widget works great, but I just discovered that if I drop two of these widgets onto the same page, only one of them works! And I'm quite certain the reason is because the chat window is defined in ASP, and now there are two instances of the chat window, with the same ID, on the same page.
I am doing this with straight ASP & Javascript (not by choice), so my chat window is defined as: <telerik:RadListBox ID="rlbMessages" runat="server" >
(don't mind that it's a telerik control).
So I was hoping I could do something like this: <telerik:RadListBox ID="<%= 'rlbMessages' + chatRoomID %>" runat="server" >
But from what I've gathered, apparently you can't assign ID's this way? What is the alternative?
© Stack Overflow or respective owner