如何从其他页面控制母版页中的任何内容都需要快速帮助 [英] how to control any thing in master page from other page need fast help plz

查看:86
本文介绍了如何从其他页面控制母版页中的任何内容都需要快速帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

已经尝试过此代码,但没有做任何帮助:-

this.Master.FindControl("lblMyLabelName")= this.defulatpageLabel;

我想说将标签文本从默认格式复制到母版页中的另一个标签文本

already tried this code nothing doing plz help:-

this.Master.FindControl("lblMyLabelName") = this.defulatpageLabel;

i want lets say to copy labels text from defualt to another labels text in master page

推荐答案

您可以通过这种方式检索它的一种方式
首先,在您的母版页代码后面,尝试创建一个属性,该属性公开要访问的控件.
Hi One way you can retrive it by this way
First in your master page code behind try to create a property that exposes this control you are going to access.
public String LabelValue
{
        get { return lblinMaster.Text; }
}


然后在内容页面(ASPX)中添加对master的引用.


Then in your content page (ASPX) add a reference to master.

<%@ MasterType VirtualPath="~/MasterPage.master" %>


完成后,您可以在后面的内容页面代码中访问Master.LabelValue.

当然,如果您想控制所有内容,请尝试创建一个基础页面,并在此处保留要控制的字段,并从中继承所有页面.

谢谢,
Debata


You are done and you can access Master.LabelValue in content page code behind.

Ofcourse if you are trying to control everything, try to create a base page and keep the fields you want to control here, inherit all your pages from it.

Thanks,
Debata


您可以从aspx页面访问母版页面,也可以从母版页面访问aspx页面.我不记得现在该如何使用,但是现在您很容易找到您是否使用了google.

[ ^ ]
You can get to the master page from the aspx page , and to the aspx page from the master page. I don''t recall how right off hand, but I now it''s easy to find if you use google.

2.75 MILLION google results for "access aspx page from master page"[^]


Label masterLabel = (Label)this.Master.FindControl("lblMyLabelName");


这篇关于如何从其他页面控制母版页中的任何内容都需要快速帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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