我正在尝试使用Aspx页面中的jQuery对话框打开用户控件(Child.ascx)作为弹出窗口。
我在 Child.ascx
文件中包含了 Child.aspx
。现在在Main.aspx
我想将**Child.aspx**
称为弹出窗口。
Main.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();
}
Child.aspx
<body>
<form id="form1" runat="server">
<div id="result">
</div>
</form>
</body>
请建议。
由于
BB
答案 0 :(得分:1)
您可以在弹出窗口中打开child.aspx。您可以通过两个步骤完成此任务:
1)使用$(“#child”)将child.aspx加载到主页的隐藏容器中.load ...
2)使用对话框打开弹出窗口:$(“#child”)。dialog ...