0

I have a code which I have to use HTML elements instead of ASP.NET elements. So because I want to have access to the elements from CodeBehind I've set all of their attributes to runat=server.

As you know ASP.NET changes the name attribute of elements to something like CT100$MainContent$IDNameOfThatElement. How can I prevent ASP.NET to change it? Cuz I have to have some other names because of JQuery stuff...

For example ASP.NET changes the name attribute from required to CT100$MainContent$PaymentCode in the following code:

<div class="field">
   <input type="text" runat="server" name="required" id="PaymentCode" />
</div>

Thanx in advance.

scartag
  • 17,548
  • 3
  • 48
  • 52
Payam Sh
  • 581
  • 4
  • 9
  • 21

2 Answers2

1

You have to add ClientIDMode="Static"

Example:

<asp:Panel ID="myPanel" runat="server" ClientIDMode="Static">
</asp:Panel>
haraiza
  • 36
  • 3
-1

As far as I know you can't override the name attribute without jumping through some hoops. What you can do is create a controlAdapter that can control which attributes will be rendered and how.

Have a look at this answer for an idea about how to accomplish your goal.

Community
  • 1
  • 1
Falle1234
  • 5,013
  • 1
  • 22
  • 29