Quantcast
Channel: PipisCrew Official Homepage
Viewing all articles
Browse latest Browse all 11347

Extending jquery to select ASP.NET controls

$
0
0

2015

ref – http://www.codeproject.com/Articles/34151/ASP-NET-Client-ID-Feature
add html attribute

clientidmode="Static"

to retain the id!

 


 

2009

 
http://www.foliotek.com/devblog/extending-jquery-to-select-asp-controls/

If you have worked with JavaScript in an ASP.NET Web Forms environment, you almost certainly have been frustrated that this markup:

	<asp:textbox runat="server" id="txtPhoneNumber"></asp:textbox>

renders out as something like:

	<input type="text" id="ctl00_ctl00_ctl00_main_Content_txtPhoneNumber" name="ctl00$ctl00$ctl00$main$Content$txtPhoneNumber">

 
 
 
github – https://gist.github.com/bgrins/4148366
 

// Include this function before you use any selectors that rely on it
	if ($.expr.createPseudo) {
	  jQuery.expr[':'].asp = $.expr.createPseudo(function( id ) {
		  return function(elem) {
			  return elem.id && elem.id.match(id + "$")
		  };
	  });
	}
	else {
		jQuery.expr[':'].asp = function(elem, i, match) {
			return !!(elem.id && elem.id.match(match[3] + "$"));
		};
	}

	// Now all of these are valid selectors
	// They show why this method has more functionality than the previous $asp() function.
	$(":asp(txtPhoneNumber)")
	$("input:asp(txtPhoneNumber):visible")
	$(":asp(txtPhoneNumber), :asp(txtAddress)")
	$("ul:asp(listTodos) li")
	$("#content").find("ul:asp(listTodos)")

Viewing all articles
Browse latest Browse all 11347

Trending Articles