Code behind and master page
<%@ Page Language="C#" MasterPageFile="~/Default.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Default" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderId="ContentPlaceHolder1"
Runat="server">
<b>Enter your name:</b><br />
<asp:Textbox ID="TextBox1" Runat="server" />
<asp:Button ID="Button1" Runat="server" Text="Submit"
OnClick="Button1_Click" /><br />
<br />
<asp:Label ID="Label1" Runat="server" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderId="ContentPlaceHolder2" Runat="server">
<asp:Image ID="Image1" Runat="server" ImageUrl="http://www.java2s.com/style/logo.png" />
</asp:Content>
File: Default.aspx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class Default : System.Web.UI.Page
{
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = "<b>Hello " + TextBox1.Text + "!</b>";
}
}
File: Default.master
<%@ Master Language="C#" %>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>My Company Master Page</title>
</head>
<body>
<form id="form1" runat="server">
<table>
<tr>
<td colspan="2">
<h1>My Company Home Page</h1>
</td>
</tr>
<tr>
<td>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" Runat="server"/>
</td>
<td>
<asp:ContentPlaceHolder ID="ContentPlaceHolder2" Runat="server"/>
</td>
</tr>
<tr>
<td colspan="2">
Copyright 2006 - My Company
</td>
</tr>
</table>
</form>
</body>
</html>
Related examples in the same category