i found a required control with jquery like below…
the control source:
<a id="ctl00_ContentPlaceHolder1_rlvImages_ctrl0_ctrl3_lbEdit" class="lbEdit" href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$rlvImages$ctrl0$ctrl3$lbEdit','')">ویرایش</a>
the jquery code:
alert($(‘a[id$=”lbEdit”]’));
i want to know what is the difference between
ctl00_ContentPlaceHolder1_rlvImages_ctrl0_ctrl3_lbEdit
and
ctl00$ContentPlaceHolder1$rlvImages$ctrl0$ctrl3$lbEdit
and how can i get
ctl00$ContentPlaceHolder1$rlvImages$ctrl0$ctrl3$lbEdit
with jquery?
mean i need to check the upper id or whatever in a condition and i think hardcode the upper id is not the correct way …
Firstly,
ctl00_ContentPlaceHolder1_rlvImages_ctrl0_ctrl3_lbEditis the HTML Id attribute of the element.ctl00$ContentPlaceHolder1$rlvImages$ctrl0$ctrl3$lbEditis the internal ASP.Net reference of the element. It has no use to the front-end of the site.In your example, to get the text of that element using a jQuery selector, you would use:
It’s also worth noting that using ASP.Net webforms will mean that you cannot rely on the ID of that element being that same forever. You would have to pinpoint that specific element via it’s class (which you can set reliably in ASP.Net) and it’s parent(s).