javascript - ScriptManager.RegisterClientScriptBlock 无法打开特定大小的窗口

标签 javascript asp.net asp.net-ajax

大家好,我试图通过 asp 按钮单击事件在对话框窗口中打开一个 aspx 页面,但即使在指定对话框高度和对话框宽度之后,我希望我可以看到以默认大小打开的对话框窗口。看起来高度我传递的宽度参数将被忽略。

这是服务器端代码:

ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(),Guid.NewGuid().ToString(), "try { showMessageRulesDialog('MessageRuleCenterFrame.htm', true); }catch(e){alert(e);}", true); 

JavaScript 代码:

function showMessageRulesDialog(dialogName, refresh) 
{
try {

    var WinSettings =       "wcenter:yes;resizable:no;onscroll:off;dialogHeight:700px;dialogWidth:610px;";
    var ret = window.showModalDialog("../Dialogs/" + dialogName,"", WinSettings);
    if (refresh) {
        window.location = window.location;
    }
}
catch (e)
{ alert("ShowDialog Error: " + e); }
}

HtmPage 属性

<iframe src="MessageRulesCenter.aspx"  style="height:700px;width:610px;" frameborder="0"   scrolling="yes"></iframe>

MessageRulesCenter.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="MessageRulesCenter.aspx.cs"  Inherits="Dialogs_QuotaCenter" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<%--<base target="_blank" /> --%>
<title>Quota Message Center</title>
<link rel="Stylesheet" href="../Skins/QuotaCenter.css" />
<script language="javascript" type="text/javascript" src="../Scripts/Common.js"></script>
<style type="text/css">
    #form1
    {
        height: 450px;
        width: 581px;
    }
     .formfield * {
         vertical-align: middle;
         border-width:0px;
    }
</style>
</head>
<body style="text-align: left">
<form id="form1" runat="server">      
    <table style="height: 437px; width: 582px"  >
        <tr>
           <td bgcolor="#91ACFF">

              <div class="Section" id="Sec1">                      
                <div>
                  <br /> &nbsp;
                 <asp:Label ID="Label1" runat="server"  Text="Message Rule Name : " 
                   ForeColor="Black" Font-Bold="False"></asp:Label>                     
                 <asp:TextBox ID="txtRuleName" runat="server"></asp:TextBox>
                   <br /><br />
                </div>

                <div>
                  &nbsp;&nbsp;<asp:Label ID="Label2" runat="server" ForeColor="Black" 
                  Text="Create Message Rule On :" Font-Bold="False"></asp:Label>                      
                    <br />
                    <br />
                </div>                    

              </div>

              <div class="Section" id="Sec2">

                <div>
                  &nbsp;&nbsp;&nbsp;&nbsp;
                  <asp:RadioButton ID="rdoIncoming" GroupName="MessageRules" runat="server" ForeColor="Black" 
                      Text="Incoming Message" AutoPostBack="True" 
                        oncheckedchanged="rdoOutgoing_CheckedChanged" />
                  <asp:RadioButton ID="rdoOutgoing" GroupName="MessageRules"  runat="server" ForeColor="Black" 
                      Text="Outgoing Message" oncheckedchanged="rdoOutgoing_CheckedChanged" 
                        AutoPostBack="True" />
                    <br />
                  <br />
                </div> 
                <div>
                    &nbsp; 
                    <asp:Label ID="Label3" runat="server" ForeColor="Black" Text="Where"></asp:Label>
                    <br />
                </div>

                <div>
                   <p class="formfield">
                         &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        <asp:Label ID="lblField1" runat="server" ForeColor="Black" Text="From field Contains :"></asp:Label>
                         &nbsp;
                       <asp:TextBox ID="txtField3" runat="server" Width="272px" TextMode="MultiLine"></asp:TextBox>
                         &nbsp;&nbsp;&nbsp;
                       <asp:Button ID="btnAddContact" runat="server" Text="Add Contact" Width="102px" onclick="btnAddContact_Click"/>                   

                       <br />    
                  </p>              
               </div>

               <div>
                 <p class="formfield"> 
                 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;
                 <asp:Label ID="lblFiled2" runat="server" ForeColor="Black" Text="Subject Contains :"></asp:Label>
                   &nbsp;&nbsp;
                 <asp:TextBox ID="txtField4" runat="server" Width="270px"></asp:TextBox>
                 <br /> 
                 </p>
              </div>

             </div>
             <div class="Section" id ="Sec3">  

                <div>
                     &nbsp;&nbsp;                     
                     <asp:Label ID="Label4" runat="server" ForeColor="Black" Text="Then"></asp:Label>
                </div>
                 <div>
                     <p class="formfield">
                  &nbsp;&nbsp;&nbsp;&nbsp;
                         <asp:RadioButton ID="rdoMove" runat="server" GroupName ="ActionType" ForeColor="Black" Text="Move it to the Folder : " />
                  &nbsp;&nbsp; 
                         <asp:DropDownList ID="ddlMove" runat="server" Width="165px" onselectedindexchanged="ddlMove_SelectedIndexChanged" >
                         </asp:DropDownList>
                     </p>
                 </div>
                 <div>
                     <p class="formfield">
                     &nbsp;&nbsp;&nbsp;&nbsp;
                         <asp:RadioButton ID="rdoCopy" runat="server" GroupName ="ActionType" ForeColor="Black" Text="Copy it to the Folder : " />
                      &nbsp;&nbsp;
                         <asp:DropDownList ID="ddlCopy" runat="server" Width="165px" onselectedindexchanged="ddlMove_SelectedIndexChanged" >
                         </asp:DropDownList>
                     </p>
                 </div>
                 <div style="text-align:right">
                    <asp:Label ID="lblError" runat="server"></asp:Label>
                    <p class="formfield">                           
                     <asp:Button ID="btnDone" runat="server" Text="Done" OnClick="btnDone_Click" Width="61px" />
                     <asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="Cancel" />
                    </p>
                 </div>                    
              </div>               

           </td>
          </tr>

       </table>      
</form>

最佳答案

我尝试了你的代码,看起来效果很好。我猜测为什么它不能按预期工作可能是因为浏览器版本。

检查如果删除 Doctype 声明(页面最上面的行)是否获得所需的行为。

关于javascript - ScriptManager.RegisterClientScriptBlock 无法打开特定大小的窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6707834/

相关文章:

javascript - 通过 javascript 将文本(双引号存储在变量中)显示到模态时遇到问题

html - ASP 动态菜单子(monad)菜单鼠标悬停在子菜单上时消失。

asp.net - 使用 ASP.NET Identity 创建无密码的用户

c# - 使用 ASP.NET MVC 5,如何获取 View 中枚举值的本地化 DisplayAttribute 字符串?

asp.net - ASP.NET Rich UI-您使用什么?

javascript - 当 JavaScript 动态添加行时,单选按钮功能无法正常工作

javascript - 如何用 react-testing-library 模拟内容溢出?

asp.net - 在运行时将客户端事件添加到 ASP.Net 自定义控件

javascript - 对 Angular $resource 查询进行测试显示找不到 ngResourceProvider 错误

jQuery AJAX 不发送数据