Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post May 03, 2010 05:14 AM by sundeep_38
May 02, 2010 10:02 AM|LINK
Recently i have been trying to jQuery with ASPX page which works fine
but if the aspx page is a content page of some master page i have issues.
The issue is
I pass my ASP control id directly to jQuery but if that control is on content page the control name changes as master page adds additional information infront of the control name in the browser.
ASP Image ID:imgCrop changed to ctl00_MainContent_imgCrop where
MainContent is the name of Content place holder.
Is there way to sort out this issue?
or i rather pass this id ctl00_MainContent_imgCrop to jQuery? Which i am already doing and seems to work fine.
May 02, 2010 12:20 PM|LINK
Yes, if you use master pages and user controls clientids of server controls will change.
You can hard code the values as you are doing right and send it to jQuery but its not preffered. Because if there is any name change of user control or master page, again you need to go to all your pages and manually change things.
Instead, if you have all your controls in a page you can pass ClientID property of control. For ex:<%=txtName.ClientID%>
This way you will have clientid's of server controls.
May 03, 2010 02:35 AM|LINK
so if this is my present jQuery where i have hardcoded
I should change it to this?
May 03, 2010 05:14 AM|LINK
If imgCrop is server side control and this function is placed in aspx page.
Code will change this way