Step
1 :- (Parent.aspx)
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Parent.aspx.cs" Inherits="Demo.Parent" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
function OpenPopup()
{
window.open("Child.aspx", "myWindow", "width=200,
height=100");
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Text="Label">
</asp:Label>
<br />
<asp:Button ID="Button1" runat="server" Text="Button
Popup" />
<br />
<asp:LinkButton ID="LinkButton1" runat="server" Text="Link
button Popup" />
<br />
</div>
<div>
<asp:GridView ID="GridView1" EmptyDataText="No
Data available" runat="server" CellPadding="4" ForeColor="#333333" GridLines="None">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="LinkButton2" runat="server" OnClientClick="OpenPopup()">Gridview
Popup</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EditRowStyle BackColor="#2461BF" />
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#EFF3FB" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F5F7FB" />
<SortedAscendingHeaderStyle BackColor="#6D95E1" />
<SortedDescendingCellStyle BackColor="#E9EBEF" />
<SortedDescendingHeaderStyle BackColor="#4870BE" />
</asp:GridView>
</div>
</form>
</body>
</html>
Step 2 :- (Parent.aspx.cs)
using System;
using System.Data;
using System.Globalization;
using System.Web.UI;
namespace Demo
{
public partial class Parent : Page
{
protected void Page_Load(object sender, EventArgs e)
{
Label1.Text
= DateTime.Now.ToString(CultureInfo.InvariantCulture);
if (!Page.IsPostBack)
{
Button1.Attributes.Add("onclick", "javascrip:OpenPopup()");
LinkButton1.Attributes.Add("onclick", "javascrip:OpenPopup()");
DataSet ds=new DataSet();
ds.ReadXml(Server.MapPath("~") + "XMLFile1.xml");
GridView1.DataSource
= ds;
GridView1.DataBind();
}
}
}
}
Step 3 :- (Child.aspx)
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Child.aspx.cs" Inherits="Demo.Child" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
function ClosePopup()
{
window.close();
//window.opener.location.reload();
window.opener.document.location.href
= "Parent.aspx";
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="Close
Popup" />
</div>
</form>
</body>
</html>
Step 4 :- (Child.aspx.cs)
using System;
using System.Web.UI;
namespace Demo
{
public partial class Child : Page
{
protected void Page_Load(object sender, EventArgs e)
{
Button1.Attributes.Add("onclick", "javascript:ClosePopup()");
}
}
}
Step 5:- (XMLFile1.xml)
<?xml version="1.0" encoding="utf-8" ?>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't
forget me this weekend!</body>
</note>
Step 6:- Sample
No comments:
Post a Comment