| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2333 人关注过本帖
标题:循环为控件赋值
只看楼主 加入收藏
魔城侠客
Rank: 1
等 级:新手上路
帖 子:200
专家分:0
注 册:2006-4-4
收藏
得分:0 

对,现在问题这些控件在普通页面上时候可能通过循环为各控件赋值
但是这些控件如果是在母版页的内容生成页上时循环就不能找到这些控件了


West and east,home is best……
2007-11-18 15:01
imbug
Rank: 1
等 级:新手上路
帖 子:23
专家分:0
注 册:2007-8-17
收藏
得分:0 
这儿有微软的一个例子http://msdn2.microsoft.com/zh-cn/library/xxwa0ff0(VS.80).aspx 希望能对你有所帮助。
母板页是2005 新引进的概念吧,我这儿现在还用2003呢,看样也要装个05学学了!!

void Page_Load()
{
// Gets a reference to a TextBox control inside
// a ContentPlaceHolder
ContentPlaceHolder mpContentPlaceHolder;
TextBox mpTextBox;
mpContentPlaceHolder =
(ContentPlaceHolder)Master.FindControl("ContentPlaceHolder1");
if(mpContentPlaceHolder != null)
{
mpTextBox =
(TextBox) mpContentPlaceHolder.FindControl("TextBox1");
if(mpTextBox != null)
{
mpTextBox.Text = "TextBox found!";
}
}

// Gets a reference to a Label control that not in
// a ContentPlaceHolder
Label mpLabel = (Label) Master.FindControl("masterPageLabel");
if(mpLabel != null)
{
Label1.Text = "Master page label = " + mpLabel.Text;
}
}

[此贴子已经被作者于2007-11-18 15:26:19编辑过]

2007-11-18 15:25
魔城侠客
Rank: 1
等 级:新手上路
帖 子:200
专家分:0
注 册:2006-4-4
收藏
得分:0 
终于搞定了
非常感谢imbug

West and east,home is best……
2007-11-18 18:02
冰彩虹
Rank: 4
来 自:上海
等 级:贵宾
威 望:14
帖 子:806
专家分:44
注 册:2007-6-28
收藏
得分:0 
对头,我把ContentPlaceHolder给忘了

Flying without wings
2007-11-18 20:13
CtrlJava
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2010-7-16
收藏
得分:0 
写的挺好的但不够简洁
2011-04-01 16:55
快速回复:循环为控件赋值
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.020049 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved