Wednesday, December 21, 2011

Page Popup

First Pagre


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"%>

<html xmlns="http://www.w3.org/1999/xhtml"%>
<head runat="server"%>
%<title%>Untitled Page%</title%>
</head%>
<body%>
<form id="form1" runat="server"%>
<div>
Click Here To open popup Window
<br />
<asp:Button ID="btnPopup" runat="server" Text="Pop Up" /%>
</div%>
</form%>
</body%>
</html%>

Codebehind Page


public partial class Default3 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
btnPopup.Attributes.Add("onclick", "window.open('Child.aspx',null,'left=200, top=30, height=550,width= 500, status=no, resizable= yes, scrollbars= yes, toolbar= no,location= no, menubar= no');");
}
}

Popup Page


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="child.aspx.cs" Inherits="child" %%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"%>

<html xmlns="http://www.w3.org/1999/xhtml"%>
<head runat="server"%>
<title>Untitled Page</head%>
<body>
<form id="form1" runat="server"%>
<div%>
This is is a child Page.
<asp:Button ID="btnClose" runat="server" Text="Close" /%>
</div%>
</form%>
</body%>
</html%>

Codebehind Page -To close the window


public partial class child : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
btnClose.Attributes.Add("onclick","window.opener.location.reload();window.close()");
}
}

No comments:

Post a Comment