0

I'd like to fix name value in server. .Net change the actual field name when render the control in page. How to fix the value?

If I write ClientIDMode="Static" id's not change. I don't want this.

<input type="text" name="username" runat="server" id="inputName" />

rendered <input name="ctl00$MainContent$inputName" type="text" id="inputName" class="form-control" placeholder="First name" clientid="static" />

baros
  • 241
  • 2
  • 7
  • 22

1 Answers1

0

that is called name prefix and .net does that by adding containers & dynamic controls naming as prefix. its basically to ensure unique id of each control rendered dynamically, to stop this behavior, you need to change following in web.config :

<system.web>
<pages clientIDMode="Static">
</pages> 
</system.web> 

There are other clientidmodes also available, such as predictable , inherit or AutoID, which you maybe want to play around. Hope this helps.

Alok
  • 808
  • 13
  • 40
  • It doesn't work still comes prefix to name property. – baros Jul 09 '14 at 11:47
  • 1
    asp.net doesn't provide a way yet to make clientname static althought you can get dynamic client name by using <%= controlid.UniqueId%> this will give you the name for scripting purposes on client side. Also you can look in here: http://stackoverflow.com/questions/5792290/input-name-and-id-changes-when-set-runat-server – Alok Jul 09 '14 at 12:15