如何对母版页中的用户控件进行操作? 一个页面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# 打印當前開啟的頁面 TFS 下工程添加后无法CHECK IN的问题!!标题要长!!分数要多!! 如何使重构的方式封装字段时不检查其他对象? MailMessage发送邮件,收到的邮件只有前面一部分,如何解决? 怎么样实现 悬浮广告 ????谢谢!!! 图片问题,在什么事件里重画,具体怎么 画,望高手指教!!!!! C#新建SQL数据表时出问题 关于接口的问题? 迭代一个类和迭代一个类成员有什么区别呢 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操作就是对你的控件的操作