ModalDialog窗体没有'我工作不好

ModalDialog form doesn't work well

本文关键字:工作 窗体 ModalDialog      更新时间:2023-09-26

我有一个应用程序页面。我想点击一个按钮弹出另一个应用程序页面中的对话框。对话很快出现并消失在空中。当然,它没有显示页面的正确上下文。我正在使用SharePoint 2010和Visual Studio 2010。我也使用母版页。谢谢

<asp:Content ID="PageHead" ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server">
<link href="../Stylesheet.css" rel="stylesheet" type="text/css" />
<SharePoint:ScriptLink runat="server" Name="sp.js" OnDemand="true" LoadAfterUI="true" Localizable="false" />
 </asp:Content>
<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
<div id="wrap">
    <div id="nav">
        <asp:Button ID="Edit" runat="server" Text="Edit" OnClientClick="javascript:Edit_Click()">
        </asp:Button> 
        <script type="text/javascript">
            function Edit_Click() {
                              SP.SOD.executeFunc("sp.js");
                              var options = SP.UI.$create_DialogOptions();
                              options.title = "My Dialog Title";
                              options.width = 400;
                              options.height = 600;
                              options.url = "/_layouts/Admin/test.aspx";
                              SP.UI.ModalDialog.showModalDialog(options);
                        };

            </script>
    </div>

对话框显示然后消失的原因是您的asp:Button执行回发。

尝试使用

<asp:Button ID="Edit" runat="server" Text="Edit" OnClientClick="javascript:Edit_Click(); return false;" />

以防止回发。

试试这个兄弟。(..)

function Edit_Click() {
     $("#app_setup_wizard_container").dialog({
        autoOpen:false,
        height: 'auto',
        width: 'auto',
        resize:false,
        modal: true,
        position: [1230,220],
        url = "/_layouts/Admin/test.aspx";
        open: function(event, ui) {
            var $dialog  = $(event.target);
            var position = $dialog.dialog('option', 'position');
            $dialog.closest('.ui-dialog').css({
                left: position[0],
                top:  position[1]
            });
        },
        buttons: {
            Cancel: function() {
                $(this).dialog("close");
            }
        }