I need a way to open a modal in MVC with inside a WebForm .aspx page. I've tried to open the .aspx in a new window with JavaScript.
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...
But I don't know how to...
You should be able to render it as a partial with @Html.Partial("Test")
(if using 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
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.
Have a div on the page with ID "dialog", then add a script like this:
$(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");
}
});
});
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.