Reputation: 1550
I have an update panel and inside the panel text boxes and buttons are available. Now I am using the jQuery Validation plugin, but the validation plugin is not working when it is used in the update panel.
For example:
function GetAddressTargetList() {
var objArray = new Array();
var objAddressElement = new Object();
objAddressElement = new Object();
objAddressElement.Id = "ddlAccType";
objAddressElement.Rules = "required";
objAddressElement.TargetControlType = "select";
objArray[objArray.length] = objAddressElement;
objAddressElement = new Object();
}
and in the page level (.aspx)
$(document).ready(function () {
GetAddressTargetList();
});
function pageLoad(sender, args) {
// To load the tooltip in update panel
if (args.get_isPartialLoad()) {
GetAddressTargetList();
}
}
How can I get the validation when I am using the update panel working?
Upvotes: 5
Views: 661
Reputation: 66641
I think that you have forget to initilize the pageLoad
Add this on your code:
$(document).ready(function () {
Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(PageLoaded);
});
function PageLoaded(sender, args) {
GetAddressTargetList();
}
reference: http://msdn.microsoft.com/en-us/library/bb397523(VS.100).aspx
I have update the pageLoad to PageLoaded, to avoid conflict after the comment of the rs. In my opinion the UpdatePanel have a custom way to handle the events and what we try here is to trigger the event on javascript after the UpdatePanel Updates the content.
Upvotes: 3
Reputation: 27467
Try this instead of document.ready, ajax pageLoad is called after every partial postbacks
function pageLoad() {
GetAddressTargetList();
}
Upvotes: 1