I have a simple ASP.NET page with a MasterPage. Within the MasterPage, I have two login fields:
<input type="text" runat="server" id="txtUserName"/>
<input type="text" runat="server" id="txtPassword"/>
When the controls are rendered to the page, ASP.NET renders the following:
<input type="text" runat="server" id="ctl00_txtUserName" name="ctl00$txtUserName"/>
<input type="text" runat="server" id="ctl00_txtPassword" name="ctl00$txtPassword"/>
If I understand correctly, the name
attribute corresponds to the UniqueID
property of a control. However, when I'm debugging Page_Load
and attempt to view the UniqueID
of these fields, they have different values (ctl0$txtUserName
and ctl0$txtPassword
respectively)!
Note that this does not seem to be an issue on all pages using this MasterPage. Most of them work correctly and use ctl0$txtUserName
and ctl0$txtPassword
in both rendering and Page_Load
.
Any idea what might cause ASP.NET to render a different UniqueID
for a control than it uses in Page_Load
?