ContentPlaceHolder changes the name of my dynamic controls

  • Thread starter Thread starter Roxxe
  • Start date Start date
R

Roxxe

i've got a website using masterpages, on a certain page i'm using
dynamic added controls with specific names like "q1, q2, ...", but when
i look in the sourcecode of the website it makes it like :

ctl00_ContentPlaceHolder1_q1 or even ctl00$ContentPlaceHolder1$q1

how can i fix this?
 
i've got a website using masterpages, on a certain page i'm using
dynamic added controls with specific names like "q1, q2, ...", but when
i look in the sourcecode of the website it makes it like :

ctl00_ContentPlaceHolder1_q1 or even ctl00$ContentPlaceHolder1$q1

Yes, it will do that.
how can i fix this?

You can't - you can give the content placeholder an explicit ID, but that
still won't guarantee that the name will always be the same, especially if
the control is contained within another container control e.g. a Panel or a
Table.

Luckily, you never need to worry about this. Any time you need to know the
id of the control client-side (e.g. in JavaScript validation routines), you
can get ASP.NET to provide it for you e.g.

alert('The q1 control is actually called <%=q1.ClientID%>');
 
Back
Top