Friday, November 8, 2013

jQuery not firing in Content Page derived from Master Page

If Your jquery is not working in Content Page i.e. Web form using Master page than try the following

usually we get DOM by $("#ControlName")

The above method should work properly when the web form is not derived from Master Page

But when the page is derived from Master Page all controls id's are changed hence the above method will not find reference of the control

Now in order to find correct reference we should do something like this

 var reference = $("#<%=controlName.ClientID %>")

This way we can get the reference and assign it to a variable

Now using variable we can work on the control like we usually do it jquery

I hope it was informative for you, and I would like to Thank you for reading

No comments:

Post a Comment