1.
Hvorfor har du så en master?
2.
Ok
3.
Du kan godt få fat i dem, hvis du kalder FindControl(...) på din contentplaceholder.
Et eksempel:
// din master:
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="SomeMaster.master.cs" Inherits="SomeMaster" %>
<!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>
<asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
</asp:contentplaceholder>
<br />
<asp:Button ID="UxSave" runat="server" OnClick="UxSave_Click" Text="Save" /><br />
<br />
<asp:Label ID="UxMessage" runat="server"></asp:Label></div>
</form>
</body>
</html>
// og koden
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 SomeMaster : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void UxSave_Click(object sender, EventArgs e)
{
TextBox name = ContentPlaceHolder1.FindControl("UxName") as TextBox;
TextBox age = ContentPlaceHolder1.FindControl("UxAge") as TextBox;
string message = String.Format("Du hedder {0} og er {1} år", name.Text, age.Text);
UxMessage.Text = message;
}
}
// din contentside
<%@ Page Language="C#" MasterPageFile="~/SomeMaster.master" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:TextBox ID="UxName" runat="server"></asp:TextBox><br />
<asp:TextBox ID="UxAge" runat="server"></asp:TextBox>
</asp:Content>
// og koden til den
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 Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
Altså ingen kode.
Det er så igen sjældent særlig hensigtsmæssigt at du tilgår contentsider fra masteren, men hvis dit scenarie er, at din content og master er et sammentømret par går det jo nok.
Mvh