如何对母版页中的用户控件进行操作? 一个页面A.aspx的母版页为master.master,现在想在a.aspx中对master.master中的一个用户控件left.ascx中的属性进行操作,应该怎么写? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 楼主实际在问两个问题:(1)如何访问master页面:用master.findcontrol(".....")(2)用户控件的类:用asp.进行,如果不明确,可以用gettype将它输出,这样你就看明白了。 比如我想通过a.aspx页面的代码,给master.master母板页中left.aspx用户组件的属性abc赋值,要怎么写呢? 在masterpage中定义方法:public void changelabel(string s1) { this.Left1.label.Text = s1; }在内容页中加入引用:<%@ MasterType virtualPath="~/MasterPage.master"%> 然后可以在内容页中直接调用masterpage中的公开方法. 在masterpage中定义方法:public void changelabel(string s1) { this.Left1.label.Text = s1; }在内容页中加入引用:<%@ MasterType virtualPath="~/MasterPage.master"%> 然后可以在内容页中直接调用masterpage中的公开方法. 有没有办法直接对left1中的控件进行操作呢?否则的话,我不是每个模板都要写上这些方法? 有没有搞错?为什么要引用页?那不是烦死了?以上代码在内容页中某按钮中 Control ctltmp = null; Panel plTmp = null; ctltmp = null; ctltmp = Page.Master.FindControl("plMstSeach");//plMstSeach是母版页中的控件ID if (ctltmp != null) { plTmp = (Panel)ctltmp; clsBase.funSetPanelPos(plTmp, 60, 50);//这个是对母版页中的Panel进行位置设定,plTmp就是母版页中的控件 } clsBase.funSetPanelPos是自己写的函数,不是系统哈,不要搞错了。对plTmp操作就是对你的控件的操作 酒店客房实时房态图 c# winform中怎么实现文本框自动补全功能 五子棋 socket 发送落子座标 怎么转换数据 菜鸟又来请教~ datagridview奇怪问题,关闭窗体再次使用时候总是把已经设置好的列变成零了 求vs.net 2003 下载地址,要求能用 不知道为什么 ----------C# 调用 Dll的问题,有结果100分相送,今晚必须出结果,谢谢 如果移动没有标题栏的窗口? 咱们来个集思广益,知道C#与java的不同点,在这里列举一下。 迭代一个类和迭代一个类成员有什么区别呢 GridView 的标题行
(1)如何访问master页面:用master.findcontrol(".....")
(2)用户控件的类:用asp.进行,如果不明确,可以用gettype将它输出,这样你就看明白了。
public void changelabel(string s1)
{
this.Left1.label.Text = s1;
}
在内容页中加入引用:
<%@ MasterType virtualPath="~/MasterPage.master"%>
然后可以在内容页中直接调用masterpage中的公开方法.
public void changelabel(string s1)
{
this.Left1.label.Text = s1;
}
在内容页中加入引用:
<%@ MasterType virtualPath="~/MasterPage.master"%>
然后可以在内容页中直接调用masterpage中的公开方法.
以上代码在内容页中某按钮中
Control ctltmp = null;
Panel plTmp = null; ctltmp = null;
ctltmp = Page.Master.FindControl("plMstSeach");//plMstSeach是母版页中的控件ID
if (ctltmp != null)
{
plTmp = (Panel)ctltmp;
clsBase.funSetPanelPos(plTmp, 60, 50);//这个是对母版页中的Panel进行位置设定,plTmp就是母版页中的控件
}
对plTmp操作就是对你的控件的操作