LET ONE BUTTON IN MASTER PAGE THAT BUTTON WE ACCESS IN CHILD PAGE
Master Page Source File
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>
<!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></title>
<link href="Styles/MainClass.css" rel="Stylesheet" type="text/css" />
<%-- <style type="text/css">
.style1
{
width: 100%;
height: 526px;
}
.style2
{
width: 199px;
}
</style>--%>
</head>
<body>
<form id="form1" runat="server">
<table >
<tr>
<td>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="btnsave" runat="server" Text="Save" />
<br />
<asp:Button ID="Button1" runat="server" Text="Delete" />
</td>
<td>
<asp:Image ID="Image1" runat="server" ImageUrl="~/Image/utilities.jpg" CssClass="masterpageMiddleheaderimage"/>
</td>
</tr>
<tr>
<td class="masterleftwhite"></td>
<td>
<asp:Menu ID="Menu1" runat="server" Orientation="Horizontal"
CssClass="menulist" BorderStyle="Inset" BorderWidth="1px"
ForeColor="#FF9966" Height="12px" RenderingMode="List" >
<Items>
<asp:MenuItem Text="Satya" Value="Satya" ></asp:MenuItem>
<asp:MenuItem Text="Linku" Value="Linku"></asp:MenuItem>
<asp:MenuItem Text="Hari" Value="Hari"></asp:MenuItem>
</Items>
</asp:Menu>
</td>
</tr>
<tr>
<td >
<asp:Panel ID="Panel1" runat="server" CssClass="masterpageleftdownimage">
<asp:LinkButton ID="LinkButton1" runat="server" Text="Satya"/>
<asp:LinkButton ID="LinkButton2" runat="server" Text="Satya"/>
<asp:LinkButton ID="LinkButton3" runat="server" Text="Satya"/>
</asp:Panel>
</td>
<td>
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
</tr>
</table>
</form>
</body>
</html>
Child Page Source Code
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="addMasterpage.aspx.cs" Inherits="addMasterpage" %>
<%@ MasterType VirtualPath="~/MasterPage.master" %> <//This Is Main For add this code Child Page//>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div class="InnerContent3WOI">
<div class="labeldiv">
Roll
</div>
<div class="valuediv">
<asp:TextBox ID="toll" runat="server" />
</div>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</div>
</asp:Content>
C# Coading
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class addMasterpage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Button b =(Button)Master.FindControl("btnsave");
b.Click+=new EventHandler(b_Click);
}
protected void b_Click(object sender, EventArgs e)
{
Label1.Text = "Call the MAster Page Events";
}
}
Master Page Source File
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>
<!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></title>
<link href="Styles/MainClass.css" rel="Stylesheet" type="text/css" />
<%-- <style type="text/css">
.style1
{
width: 100%;
height: 526px;
}
.style2
{
width: 199px;
}
</style>--%>
</head>
<body>
<form id="form1" runat="server">
<table >
<tr>
<td>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="btnsave" runat="server" Text="Save" />
<br />
<asp:Button ID="Button1" runat="server" Text="Delete" />
</td>
<td>
<asp:Image ID="Image1" runat="server" ImageUrl="~/Image/utilities.jpg" CssClass="masterpageMiddleheaderimage"/>
</td>
</tr>
<tr>
<td class="masterleftwhite"></td>
<td>
<asp:Menu ID="Menu1" runat="server" Orientation="Horizontal"
CssClass="menulist" BorderStyle="Inset" BorderWidth="1px"
ForeColor="#FF9966" Height="12px" RenderingMode="List" >
<Items>
<asp:MenuItem Text="Satya" Value="Satya" ></asp:MenuItem>
<asp:MenuItem Text="Linku" Value="Linku"></asp:MenuItem>
<asp:MenuItem Text="Hari" Value="Hari"></asp:MenuItem>
</Items>
</asp:Menu>
</td>
</tr>
<tr>
<td >
<asp:Panel ID="Panel1" runat="server" CssClass="masterpageleftdownimage">
<asp:LinkButton ID="LinkButton1" runat="server" Text="Satya"/>
<asp:LinkButton ID="LinkButton2" runat="server" Text="Satya"/>
<asp:LinkButton ID="LinkButton3" runat="server" Text="Satya"/>
</asp:Panel>
</td>
<td>
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
</tr>
</table>
</form>
</body>
</html>
Child Page Source Code
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="addMasterpage.aspx.cs" Inherits="addMasterpage" %>
<%@ MasterType VirtualPath="~/MasterPage.master" %> <//This Is Main For add this code Child Page//>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div class="InnerContent3WOI">
<div class="labeldiv">
Roll
</div>
<div class="valuediv">
<asp:TextBox ID="toll" runat="server" />
</div>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</div>
</asp:Content>
C# Coading
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class addMasterpage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Button b =(Button)Master.FindControl("btnsave");
b.Click+=new EventHandler(b_Click);
}
protected void b_Click(object sender, EventArgs e)
{
Label1.Text = "Call the MAster Page Events";
}
}
No comments:
Post a Comment