Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify javascript to run when ModalPopupExtender is shown

The ASP.NET AJAX ModalPopupExtender has OnCancelScript and OnOkScript properties, but it doesn't seem to have an OnShowScript property. I'd like to specify a javascript function to run each time the popup is shown.

In past situations, I set the TargetControlID to a dummy control and provide my own control that first does some JS code and then uses the JS methods to show the popup. But in this case, I am showing the popup from both client and server side code.

Anyone know of a way to do this?

BTW, I needed this because I have a textbox in the modal that I want to make a TinyMCE editor. But the TinyMCE init script doesn't work on invisible textboxes, so I had to find a way to run it at the time the modal was shown

like image 633
slolife Avatar asked Aug 07 '08 23:08

slolife


1 Answers

hmmm... I'm pretty sure that there's a shown event for the MPE... this is off the top of my head, but I think you can add an event handler to the shown event on page_load

function pageLoad() {     var popup = $find('ModalPopupClientID');     popup.add_shown(SetFocus); }  function SetFocus() {     $get('TriggerClientId').focus(); } 

i'm not sure tho if this will help you with calling it from the server side tho

like image 73
lomaxx Avatar answered Sep 20 '22 14:09

lomaxx