This
article will show you how you can show or load aspx in modal pop up in asp.net
using jquery. So when user click on button at that time popup window will open
and second page will load with in the modal pop up window using jquery.
So for this article first we will create two pages first will be used as main page and second we use to load.
So for this article first we will create two pages first will be used as main page and second we use to load.
Second
.aspx page.
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ModulatPopupPage.aspx.cs" Inherits="WebApplication1.ModulatPopupPage" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>ModelPopup</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h1>This model popup
page Example</h1>
</div>
</form>
</body>
</html>
|
After this we will create one more page and in this page we will add the below library refrence.
<link rel="stylesheet"
href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
|
Now we will
create below control.
<div id="dialog" title=".aspx
load"> </div>
<input type="button" value="Click
Me" id="btnOpen" />
|
In this one is button and other is div control so ones the user click on the button the model popup window will open and in this the .aspx page load at run time.
Now we will
check the jQuery code.
$(function () {
$("#dialog").dialog(
{
autoOpen: false
});
$("#btnOpen").on("click", function () {
$("#dialog").load("ModulatPopupPage.aspx");
$("#dialog").dialog("open");
});
});
|
In above
code I have make the popup window autoopen false so that it does not open on
page load. After this i have add the button click event to open the popup
window. In this button click event I have used jquery load function to load the
.aspx page in popup window and then open the mode popup control. Now check the complete
code of the page.
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MainPage.aspx.cs" Inherits="WebApplication1.MainPage" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>How to show aspx
in modal pop up in asp.net
</title>
<link rel="stylesheet"
href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$(function () {
$("#dialog").dialog(
{
autoOpen: false
});
$("#btnOpen").on("click", function () {
$("#dialog").load("ModulatPopupPage.aspx");
$("#dialog").dialog("open");
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<div id="dialog" title=".aspx
load">
</div>
<input type="button" value="Click
Me" id="btnOpen" />
</div>
</form>
</body>
</html>
|
Now we have
done run the application to check the output.
0 comments:
Please let me know your view