Extending jQuery to Select ASP Controls
One thing that has always been annoying about programming JavaScript in an ASP.NET Web Forms environment is that the ID attribute of HTML controls rendered out from ASP controls is unpredictable.
<asp:TextBox runat="server" ID="txtPhoneNumber" />
renders out as something like:
<input type="text" id="ctl00_ctl00_ctl00_main_Content_txtPhoneNumber"
name="ctl00$ctl00$ctl00$main$Content$txtPhoneNumber" />
I did a write up over on the LANIT development blog about a solution to this problem using jQuery.
Check out the post for more details, but here is the function:
jQuery.expr[':'].asp = function(elem, i, match) {
return (elem.id && elem.id.match(match[3] + "$"));
};
$(":asp(txtPhoneNumber)").keyup(...);
December 10th, 2009 at 7:29 pm
Interesting affair, didn’t thought this would be so awesome when I saw your link!!
October 7th, 2011 at 11:04 am
adding to fav’s
December 20th, 2011 at 10:26 pm
Someone essentially help to make seriously articles I would state. This is the first time I frequented your website page and thus far? I surprised with the research you made to make this particular publish extraordinary. Fantastic job!
December 22nd, 2011 at 3:50 am
Undeniably believe that which you said. Your favorite reason seemed to be on the internet the simplest thing to be aware of. I say to you, I definitely get annoyed while people consider worries that they just do not know about. You managed to hit the nail upon the top and also defined out the whole thing without having side effect , people can take a signal. Will probably be back to get more. Thanks
December 23rd, 2011 at 10:23 am
whoah this blog is wonderful i love reading your posts. Keep up the great work! You know, lots of people are looking around for this info, you can aid them greatly.
December 27th, 2011 at 11:36 am
I will immediately grab your rss as I can’t find your email subscription link or e-newsletter service. Do you’ve any? Please let me know so that I could subscribe. Thanks.
January 7th, 2012 at 4:17 am
I liked
February 21st, 2013 at 5:37 am
A formidable share, I simply given this onto a colleague who was doing a bit of analysis on this.
And he in truth bought me breakfast because I
found it for him.. smile. So let me reword that:
Thnx for the treat! But yeah Thnkx for
spending the time to discuss this, I feel strongly about it and love reading
extra on this topic. If doable, as you turn out to be experience, would you
mind updating your blog with extra
particulars? It’s extremely helpful for me. Massive thumb up for this
weblog post!