ASP.NET:将数据从内容页传递到母版页 [英] ASP.NET: Passing data from content page to master page

查看:234
本文介绍了ASP.NET:将数据从内容页传递到母版页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的母版页中有一个名为headerLabel的标签,我想将其文本设置为内容页的标题.我该怎么做?

I have a label named headerLabel in my master page, and I'd like to set its text to the title from the content page. How do I do this?

推荐答案

在您的母版页上创建一个公共属性-类似以下内容:

On your master page create a public property - something along the lines of:

public string LabelValue
{
  get{ return this.headerLabel.Text;}
  set{ this.headerLabel.Text = value;}
}

然后,在您的子页面上,您可以执行以下操作:

Then, on your child page you can do this:

((MyMasterPage)this.Master).LabelValue = "SomeValue";

这篇关于ASP.NET:将数据从内容页传递到母版页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆