联系我们

为客户提供超预期的高品质网站设计!

C#中在内容页获取其模板页中的对象,变量,或者值

2017-11-10 0:00:00

在模板页中的程序入口改成:protected void Page_Init(object sender, EventArgs e)

在内容页:

string s1 = ((HomeMaster)this.Master).s1;


//HomeMaster是模板页的类名,也就是模板页的文件名


or


MasterPage2 masterpage2 = (MasterPage2)this.Master;
MasterPage masterpage = (MasterPage)masterpage2.Master;

Literal literal = (Literal)(masterpage.FindControl("liter1"));
Literal literalDesc = (Literal)(masterpage.FindControl("Liter_desc"));

literal.Text="www.";
literalDesc.Text="www.yaxdj.com";



母页中不需要设置title,在子页中设置title=""即可。

母版页中不要设置title就可以了。


内容页:

MasterPage masterpage = (MasterPage)this.Master;
masterpage.Page.Title = companyInfo.guanJianCi() + "-" + companyInfo.companyName() + ":" + companyInfo.companyDianHua();
masterpage.Page.MetaDescription = "上海茂联网络科技有限公司";





上一条新闻:C#获取实体类属性名和值 | 遍历类对象
下一条新闻:asp.net 随机码

 

4009-606-208 54057491 info@