At runtime, does the form's asp.net webforms form change? [duplicate]

1

At runtime, the form's asp.net webforms form changes, see that I have the component id on my machine.

Local example:

 <asp:HiddenField runat="server"  ID="MenuSelecionado" value="processo"/>

After execution, it looks like this:

<input type="hidden" name="ctl00$ContentPlaceHolder1$MenuSelecionado" id="ctl00_ContentPlaceHolder1_MenuSelecionado" value="processo">

I wonder if you have any way to keep the ID or use another property in his place.

    
asked by anonymous 24.07.2018 / 22:43

1 answer

1

You have yes, you can use ClientIDMode

<asp:HiddenField runat="server"  ID="MenuSelecionado" value="processo" ClientIDMode="Static"/>

You can see more about it at documentation

Another alternative:

Keep track like this:

<asp:HiddenField runat="server" ID="MenuSelecionado" Value="processo" />

And in Page_Load:

MenuSelecionado.ID = "MenuSelecionado";

The problem this way is that it will add the text "MainContent" before, thus getting the element

<input name="ctl00$MainContent$Bla" id="MainContent_MenuSelecionado" value="processo" type="hidden">

I'm going to do some testing if I find another way

    
25.07.2018 / 02:02