Wednesday, March 28, 2012

ASP.Net AJAX ModalPopupExtender: How to Trigger Function from the Page CodeBehind

I have a function named"btnSave_Click()" located in the codebehind of a page. The function is associated with the
click event of my button named"btnSave". It saves the values of the controls in the page to the database.

When i have added a ModalPopupExtender and associated the value"btnSave"to theOkControlID property
of the ModalPopupExtender, the popup control was displayed as i have configured it but my routines inside
thebtnSave_Click()were not anymore executed.

How can i resolve this? How can i execute a function in the codebehind of my page after clicking a button
associated with the ModalPopupExtender? I am familiar with theOnOkScriptproperty of the popup extender
but as I understand, it can only execute a script within the same page and not my codes in the codebehind.

Thank you very much.

Hi,

When a button is set as the OKControl for a ModalPopupExtender, the Extender will intercept its PostBack behavior, and just close itself when the Button is clicked.

As a result, the server side function isn't able to run.

So, please don't specify btnSave as OKControl.

Hope this helps.

No comments:

Post a Comment