如何从ASP.NET中的母版页访问内容页面控件

内容页面访问主页面控件非常简单
protected void Page_Load(object sender,EventArgs e)
{
    // content page load event
    DropDownList thisDropDown = this.Master.FindControl("someDropDown") as DropDownList;
    userLabel.Text = thisDropDown.SelectedValue;
}

但是如何从主页面访问内容页面的控件.假设内容页面中有一个文本框,在母版页中有一个按钮.我想要的是,当我点击母版页按钮时,我想在主页面标签内容页面中显示文本框的文本.怎么实现呢请帮我代码示例.谢谢.

解决方法

在主页按钮单击事件应访问页面内容: –
protected void Button1_Click(object sender,EventArgs e)
{
    TextBox TextBox1 = (TextBox)ContentPlaceHolder1.FindControl("TextBox1");
    if (TextBox1 != null)
    {
        Label1.Text = TextBox1.Text;
    }
}

相关文章

### 创建一个gRPC服务项目(grpc服务端)和一个 webapi项目(...
一、SiganlR 使用的协议类型 1.websocket即时通讯协议 2.Ser...
.Net 6 WebApi 项目 在Linux系统上 打包成Docker镜像,发布为...
一、 PD简介PowerDesigner 是一个集所有现代建模技术于一身的...
一、存储过程 存储过程就像数据库中运行的方法(函数) 优点:...
一、Ueditor的下载 1、百度编辑器下载地址:http://ueditor....