I am using JQuery 1.8.16. I have many user controls on the Page and wanna catch the edits for those if any. So, I am using Onchange event of JQuery in the Parent Page on which these User Control reside. Here's my JQuery code
$('input[type=text], input[type=file], textarea, select').on("change", function () {
var ctrl = $(this).attr('id');
if (ctrl.indexOf("ddlLibrary") != -1) {
needSave = false;
unlock = true;
UnlockRequest(null);
}
if (ctrl != null && ctrl != "") {
if (ctrl.indexOf("GeneralInformationControl") != -1
|| ctrl.indexOf("PartDetailsControl") != -1
|| ctrl.indexOf("UserInformationControl") != -1
|| ctrl.indexOf("AttachmentControl") != -1) {
if (ctrl.indexOf("lbAttachments") != -1 || ctrl.indexOf("tbAttachmetnDesc") != -1 || ctrl.indexOf("FileUpload1") != -1) {
needSave = false;
window.onbeforeunload = routeUnlock;
unlock = true;
}
else {
needSave = true;
window.onbeforeunload = confirmExit;
unlock = true;
}
}
}
});
Firstly, I doesn't catch any edits that happen for any textbox, dropdown or TextArea of my User controls on page. Secondly, I place another Method similar to this to test in documen.ready function as follows
//JQuery Function to Call Lock Method on Editing any of the User Controls on Request Page
var locked = false;
$("input,select,textarea").change(function () {
if (!locked) {
$.ajax({
type: "POST",
url: "WebForm1.aspx/methodInServer",
contentType: "application/json; charset=utf-8",
success: function (msg) {
locked = true;
alert(msg.d);
}
});
}
});
});
I put breakpoints on in these functions and I am surprised none of the break points are hit and my changes to fields in the User controls are not being caught. Any positive ideas about why this happening?
tag . All the elements should be created by that time this JQuery loads. pls clear If i am confused
– Programmerzzz Jul 08 '15 at 01:12