1

Aspx ページで jQuery ダイアログを使用して、ユーザー コントロール (Child.ascx) をポップアップとして開こうとしています。ファイルで包みChild.ascxました 。Child.aspx今、ポップアップとしてMain.aspx呼び出したい **Child.aspx**..

メイン.aspx:

 <script type="text/javascript">
        $(document).ready(function () {
            $('#btnMemo').click(function () {
                $.blockUI({ message: '<h1> Processing...</h1>' });
                var ControlName = "Child.ascx";
                $.ajax({
                    type: "POST",
                    url: "Child.aspx/Result",
                    data: "{controlName:'" + ControlName + "'}",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function (response) {
                        $.unblockUI();
             ********* /// Code to open the popup ***********
                      //  $('#result').dialog(response.d);
                    },
                    failure: function (msg) {
                        $.unblockUI();
                       ///// $('#result').html(msg);
                    }
                });
            });
        });

    </script>

..................

     <td>
      <asp:ImageButton ID="btnMemo" runat="server"  AlternateText="Memo" CausesValidation="false" ClientIDMode ="Static" />
        <div id="divMemoInfo" title="Memo"></div>
     </td>

Child.aspx.cs:

[WebMethod]
    public static string Result(string controlName)
    {
        return RenderControl(controlName);
    }

    public static string RenderControl(string controlName)
    {
        Page page = new Page();
        UserControl userControl = (UserControl)page.LoadControl(controlName);
        userControl.EnableViewState = false;
        HtmlForm form = new HtmlForm();
        form.Controls.Add(userControl);
        page.Controls.Add(form);

        StringWriter textWriter = new StringWriter();
        HttpContext.Current.Server.Execute(page, textWriter, false);
        return textWriter.ToString();
    }

子.aspx

 <body>
    <form id="form1" runat="server">
         <div id="result">
         </div>
    </form>
</body>

ご意見をお聞かせください。

ありがとう

BB

4

1 に答える 1

1

ポップアップで child.aspx を開くことができます。これは、次の 2 つの手順で実現できます。

1) $("#child").load ... を使用して、メイン ページの非表示のコンテナーに child.aspx を読み込みます。

2) ダイアログを使用してポップアップを開きます: $("#child").dialog ...

于 2012-02-13T03:32:10.767 に答える