Wednesday, 24 May 2017

How to show aspx in modal pop up in asp.net

5/24/2017 - By Pranav Singh 0

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.

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.


About the Author

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Get Updates

Subscribe to our e-mail newsletter to receive updates.

Share This Post

0 comments:

Please let me know your view

Free Ebooks


About Us

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Contact Us

For writing article in this website please send request by your

GMAIL ID: dotnetpools@gmail.com

Bugs and Suggestions

As we all know that this website is for sharing knowledge and providing proper solution. So while reading the article is you find any bug or if you have any suggestion please mail us at contact@aspdotnet-pools.com.

Partners


Global Classified : Connectseekers.com
© 2014 aspdotnet-pools.com Designed by Bloggertheme9.
back to top