Roberta Franchi
asked on
javascript user control
Hello,
I have an ascx user control and two instances of user control on the same aspx page.
I would like to add javascript to manage the postback of a button inside the user control in order to show a waiting icon and disable the button while execution.
The following javascript is working well ONLY if there is just one instance of the user control on the page but if there are two or more instances, the javascritpt is executed but in the first instance of the user control created on the page. (I mean, i I click the button of the second user control on page, the button disabled is the one of the first user control and also the <div> is shown in the first user control.
The javascript is the following:
I've tried to put this javascript code inside the web user control but...no way.
Also tried to put it inside the aspx page... but no way.
Thanks
I have an ascx user control and two instances of user control on the same aspx page.
I would like to add javascript to manage the postback of a button inside the user control in order to show a waiting icon and disable the button while execution.
The following javascript is working well ONLY if there is just one instance of the user control on the page but if there are two or more instances, the javascritpt is executed but in the first instance of the user control created on the page. (I mean, i I click the button of the second user control on page, the button disabled is the one of the first user control and also the <div> is shown in the first user control.
The javascript is the following:
// Get the instance of PageRequestManager.
var prm = Sys.WebForms.PageRequestManager.getInstance();
// Add initializeRequest and endRequest
prm.add_initializeRequest(prm_InitializeRequest);
prm.add_endRequest(prm_EndRequest);
// Called when async postback begins
function prm_InitializeRequest(sender, args) {
// get the divImage and set it to visible
var panelProg = $get('divImage');
panelProg.style.display = '';
// Disable button that caused a postback
$get(args._postBackElement.id).disabled = true;
}
// Called when async postback ends
function prm_EndRequest(sender, args) {
// get the divImage and hide it again
var panelProg = $get('divImage');
panelProg.style.display = 'none';
// Enable button that caused a postback
$get(args._postBackElement.id).disabled = false;
}
I've tried to put this javascript code inside the web user control but...no way.
Also tried to put it inside the aspx page... but no way.
Thanks
ASKER
where do I have to put it? in the ascx or aspx?
Which is the reason why this JQuery will work instead of mine?
thanks
Which is the reason why this JQuery will work instead of mine?
thanks
ASKER
solution is not working
ASKER
not working.....not working not working not working
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window