首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

想用反射给页面中的一Label赋值解决思路

2012-01-06 
想用反射给页面中的一Label赋值页面中有数Label,分别叫做lb1,lb2...lb10cs中:for(inti1i 11i++){label

想用反射给页面中的一Label赋值
页面中有数Label,分别叫做lb1,lb2...lb10
cs中:
for(int   i=1;i <11;i++){
labelName= "lb "+i;
//这里用拼好的labelName反射,得到页面中对应的Label,并将其赋值,怎么写?
}

只想用反射实现

[解决办法]
System.Type type = typeof(System.Web.UI.WebControls.Label); System.Reflection.PropertyInfo p= type.GetProperty( "Text "); string sText = p.GetValue(this.FindControl( "Label1 "),null).ToString(); Response.Write(sText);

热点排行