I have a problem with jquery not loaded in an asp user control.
I want simply to add the click event when a checkbox is clicked.
Here is my javascript file
$(document).ready(function() {
var arr = jQuery(":checkbox[id*='drpAccountType']");
for (i = 0; i < arr.length; i += 1) {
$("#" + arr[i].id).click(function() { alert(this.id) });
}
});
if (typeof (Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();
The user control pre render events:
Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender
ScriptManager.RegisterClientScriptInclude(Me, Me.GetType, "CheckboxdropdownScript", ResolveUrl("~/Scripts/CheckBoxDropDown.js"))
End Sub
the script is loaded fine but any usage of jQuery return undefined. Then only when the page is loaded I can excute the same code for the commande line in firebug. The jquery library is loaded in the master page.
Whenever I'm using jquery within an asp user control I always find problems, and I always have to hack around to get it to work. I try all the entries in stackoverflow but I never found a one as general solution.
did any one found a simple solution to use jquery with master pages, user control in asp.net I would appreciate if someone can share such valuable information.
My manager is about to drop jquery from the application as we always waist lot of time just to find a workaround to have it to work with user controls.
Please help, I like jquery and I really want to use it for client script.
best regards