0

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.

TagHeuer
  • 29
  • 8

1 Answers1

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