OK, so I have 3 different ModalPopupExtenders on my page, each with their own Panel.
The Panels all have a Cancel button.
When the user clicks on the Cancel button I want to execute a code behind function. I dont want to use the MPE CancelControlID as this only hides the modal popup and the OnClick of the Cancel button does not get called.
So, what I want to do is have a Cancel button with OnClick="CancelClicked"
Amongst other things, I want the CancelClicked function to hide the associated modal popup. How can I do this without explicitly naming the modal popup (because the function can be called from any of the 3 modals). I'm assuming that the object sender needs to be used, but how?
Thanks
Loading
Gary KingPosted Oct 17, 2011, 12:12 PM
The problem is that the Panel has no relationship back to the MPE (although the panel has a relationship to the panel via the PopupControlID property).
Therefore I don't think that it is possible to do exactly what I want to do the way that I thought it could be done.
You further suggestion to use the CancelControlID will not work either, because if you define a CancelControlID, then the OnClick function of the button itself will not execute.
However, I do have a workaround.....
If I use similar ID's for both the MPE and the Button, then I can use string manipulation to hide the MPE.
For example, MPE ID = mpeSomething and Cancel button ID = btnCancelSomething.
All I have to do is get the button ID as string, replace "btnCancel" with "mpe", cast the result as type MPE and then Hide it.
VulpesPosted Oct 17, 2011, 11:49 AM
Gary KingPosted Oct 17, 2011, 11:01 AM
Also, surely the sender is actually the button, not the MPE.
So, please could you ellaborate on how this can be achieved (code sample would be greatly appreciated)
protected void ModalCancelClicked(object sender, EventArgs e)
{
???
}
VulpesPosted Oct 17, 2011, 10:48 AM