分别设置母版页和内容页控件的值

http://topic.csdn.net/u/20090703/09/8ba3c95d-26f0-4fe7-86ba-ba035a5a2747.html?19679

MasterPage.master

<%@ 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>
</head>
<body>
    <form id="form1" runat="server">
    <div>
      <asp:Button ID="btn11" runat="server" Text="Button" /> <br />
        <asp:Button ID="btn12" runat="server" Text="Button" /><br />
        <asp:Button ID="btn13" runat="server" Text="Button" /><br />
        <asp:Button ID="btn14" runat="server" Text="Button" /><br />
        <asp:Button ID="btn15" runat="server" Text="Button" /><br />
        <asp:Button ID="btn16" runat="server" Text="Button" /><br />
        <asp:Button ID="btn17" runat="server" Text="Button" /><br />
   
        <asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
        </asp:contentplaceholder>
    </div>
    </form>
</body>
</html>
test8.aspx
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="test8.aspx.cs" Inherits="test8" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
  <asp:Button ID="btn1" runat="server" Text="Button" /> <br />
        <asp:Button ID="btn2" runat="server" Text="Button" /><br />
        <asp:Button ID="btn3" runat="server" Text="Button" /><br />
        <asp:Button ID="btn4" runat="server" Text="Button" /><br />
        <asp:Button ID="btn5" runat="server" Text="Button" /><br />
        <asp:Button ID="btn6" runat="server" Text="Button" /><br />
        <asp:Button ID="btn7" runat="server" Text="Button" /><br />       
  <asp:Button ID="Button9" runat="server" OnClick="Button9_Click" Text="test" />
</asp:Content>
test8.aspx.cs
 protected void Button9_Click(object sender, EventArgs e)
    {
        ContentPlaceHolder c = (ContentPlaceHolder)Master.FindControl("ContentPlaceHolder1");      
        object[] btn = new object[7];
        for (int i = 1; i < 8; i++)
        {
            btn[i - 1] = (Button)c.FindControl("btn" + i.ToString());
            ((Button)btn[i - 1]).Text = "修改" + i.ToString();
        }      

        object[] btn2 = new object[7];
        for (int j = 1; j < 8; j++)
        {
            btn2[j-1] = (Button)Page.Master.FindControl("btn" + (j+10).ToString());           

            ((Button)btn2[j-1]).Text = "修改" + (j+10).ToString();
        } 
    }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值