[英]How to render an .aspx page into a modal in MVC
I need a way to open a modal in MVC with inside a WebForm .aspx page. 我需要一种在WebForm .aspx页内在MVC中打开模式的方法。 I've tried to open the .aspx in a new window with JavaScript.
我试图用JavaScript在新窗口中打开.aspx。
window.open("Test.aspx", "Test", "width=800, height=600");
It works, but for the design of my project I'd like to have it in a modal. 它可以工作,但是对于我的项目设计,我希望将其以模态形式存在。
I thought to renderize the .aspx in the control and to pass the result string to JavaScript with an AJAX call... 我想在控件中渲染.aspx并通过AJAX调用将结果字符串传递给JavaScript ...
But I don't know how to... 但是我不知道该怎么办
You should be able to render it as a partial with @Html.Partial("Test")
(if using Razor). 您应该可以使用
@Html.Partial("Test")
(如果使用Razor)将其呈现为局部渲染。 I am not sure though since we don't know more about the architecture of your app. 不过我不确定,因为我们对您的应用程序的架构不了解更多。 For more info on partials: MVC Partials
有关局部的更多信息: MVC局部
You can do what you're asking about. 您可以按照自己的意愿去做。 Just load the contents of the desired page via ajax and show it in a modal dialog using jquery.
只需通过ajax加载所需页面的内容,然后使用jquery在模式对话框中显示它即可。
Have a div on the page with ID "dialog", then add a script like this: 在页面上有一个ID为“ dialog”的div,然后添加如下脚本:
$(function () {
$("#dialog").dialog({
autoOpen: false,
modal: true,
title: "WhateverPageTitleYouWant",
buttons: {
Close: function () {
$(this).dialog('close');
}
}
});
$("#ElementKickingThingsOff").click(function () {
$.ajax({
type: "GET",
url: "Test.aspx",
success: function (pageContents) {
$("#dialog").html(pageContents);
$("#dialog").dialog("open");
}
});
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.