Search code examples
asp.netcontrolsattributeswebforms

Get an ASP.NET control's auto generated name attribute?


I have a DropDownList and need to know its name in the code behind:

<select name="ctl00$cphMainContent$ddlTopic" onchange="javascript:setTimeout('__doPostBack(\'ctl00$cphMainContent$ddlTopic\',\'\')', 0)" id="ctl00_cphMainContent_ddlTopic">
<option value="All">All</option>
</select>

I need to get the value "ctl00$cphMainContent$ddlTopic"

Is that possible?


Solution

  • myddl.ClientID / myddl.UniqueID, depending on what you need, name or id attribute.