Often times when mixing jQuery with asp.net I need to use asp .net angle bracket percent, <% %>, syntax within a jQuery selector.
If I would like to separate the Jav
If you want to evaluate <% code blocks %>
as ASP.NET code in a JavaScript file, you can just put the JavaScript in an ASPX file and reference it from a SCRIPT element.
script.js.aspx
:
function hideElements()
{ <% foreach(var elementId in Request.QueryString["hide"].Split(',') { %>
jQuery('#' + <%= elementId %>).hide('slow');
<% } %>
}
page.aspx
:
page.aspx.cs
:
public string GetElementIds()
{
return string.Join(",", new []{control1.ClientID, control2.ClientID});
}