htmlasp.nethtml-inputname-attribute

Why does the 'name' attribute on my hidden input element change from what I set it to be?


Here is my markup:

<input type="hidden" runat="server" name="block" id="FSC_show_sidebar_button" value="0" />
<input type="hidden" runat="server" name="block" id="FSC_hide_sidebar_button" value="1" />

This is what it looks like when the page is rendered and I inspect it:

<input name="ctl00$MainContent$FSC_show_sidebar_button" id="ctl00_MainContent_FSC_show_sidebar_button" type="hidden" value="0"/>
<input name="ctl00$MainContent$FSC_hide_sidebar_button" id="ctl00_MainContent_FSC_hide_sidebar_button" type="hidden" value="1"/>

Is there a way to keep the 'name' attribute from changing? (Not the ID I do not care if this changes)


Solution

  • Due to the runat="server" attribute, this becomes a server side control. This would prepend your masterpage, control information to your input element.