Почему мой ModalPopupExtender не отображается?ASP.NET и JavaScript - PullRequest
0 голосов
/ 13 июля 2011

Я пытаюсь вызвать модальный расширитель всплывающих окон из JavaScript. Вот звонок:

function MyFunction()
   {alert("test");
   $find('mdlPassword').show;}

Я получаю предупреждение, когда он вызывается, но модальный всплывающий расширитель не отображается. Вот материал aspx:

<!-- Popup Extenders Should Go Here -->
<asp:button id="Button1" runat="server" text="Button" style="display: none;" />
<asp:ModalPopupExtender ID="mdlPassword" runat="server"
    targetcontrolid="Button1" popupcontrolid="pnlPassword" 
    popupdraghandlecontrolid="PopupHeader" drag="true">
</asp:ModalPopupExtender>

<asp:Panel ID="pnlPassword" style="display: none" runat="server">
<div class="PasswordPopup">
            <div id="PopupHeader">&nbsp;</div>
            <div class="Controls">
                <center><table><tr>
                    <td>Please enter your password:</td><td><input type="password" name="Password" /></td></tr>
                <tr><td>&nbsp;</td>
                    <td><asp:linkbutton id="btnOK" runat="server" text="OK" />&nbsp;&nbsp;<asp:linkbutton id="btnCancel" runat="server" text="Cancel" /></td></tr></table></center>
            </div>
 </div>
</asp:Panel>

Есть идеи?

Спасибо

Jason

1 Ответ

4 голосов
/ 13 июля 2011

Попробуйте определить BehaviorID ModalPopupExtender:

<asp:ModalPopupExtender ID="mdlPassword" runat="server"
    BehaviorID="mdlPassword"
    targetcontrolid="Button1" popupcontrolid="pnlPassword" 
    popupdraghandlecontrolid="PopupHeader" drag="true">
</asp:ModalPopupExtender>

BehaviorID : в тех случаях, когда вы хотите получить доступ к поведению на стороне клиента для вашего расширителя из кода скрипта вклиент, вы можете установить этот BehaviorID, чтобы упростить процесс.

Скрипт для отображения и скрытия всплывающего окна:

<script language="javascript">
   function showPopup()
   {
       $find('mdlPassword').show();
   }
   function hidePopup()
   {
       $find('mdlPassword').hide();
   }
</script>
...