A asp.net project was working fine since 2-3 years but now it started giving some control ID not avalilabe errors in the javascript. The controls ID were hardcoded in javascript like "ct100_mainControl_txtName" but now when I check the HTML source file the Control ID is "mainControl_txtName". I made the ID changes in the javascript it is working fine now. But how did this error appear now. What could have changed. Any suggestion will be helpful.
Asked
Active
Viewed 33 times
0
-
You've updated the website from 2.0 or 3.5 to .Net 4.0 or more. See the linked question for more details. – Adrian Iftode Mar 29 '16 at 07:29
-
How can I convert my project Target framework from 2.0 to 4.0 without using visual studio? – TagHeuer Apr 02 '16 at 06:35
1 Answers
0
When I am working with asp.net webforms I prefer to use class names for my jquery selectors. The reason for the change of id could be that you moved the control around to another container or something.
eg.
<input type="text" class="someclass" />
Then use
$('input.someclass')....
This way you are sure that when the id changes your javascript will still work.

Captain0
- 2,583
- 2
- 28
- 44
-
Yes this will work but I want to know how did that error occurred now. – TagHeuer Apr 02 '16 at 06:33