怎样根据一个名字(string),取得一个控件的控制权? rt 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 foreach (Control ctr in this.Controls) { if (ctr.Name =="radioButton3") { ((RadioButton)ctr).Checked = true; } } 谢谢如果是在aspx页里呢?怎样获得控制权? 不好意思,这几天外出了,没有时间上网..今天才看见..如果是aspx页面,也大同小异,不过在web里,控件没有"name"属性,用ClientID替代即可...foreach (Control ctr in this.Panel1 .Controls) { if (ctr.ClientID == "RadioButton2") { ((RadioButton)ctr).Checked = true; } } System.Web.UI.WebControls.Image a;a=(System.Web.UI.WebControls.Image)Page.FindControl(strTableName.ToLower()); if(a==null) { //没有找到该控件,则屏蔽该错误 } else { //a.ID=strTableName; a.ImageUrl="../a.jpg"; } Control myControl1 = FindControl("TextBox2"); if(myControl1!=null) { // Get control's parent. Control myControl2 = myControl1.Parent; Response.Write("Parent of the text box is : " + myControl2.ID); } else { Response.Write("Control not found"); } 如果在1到6个数字中选出5个有多少组应该如何编程 P2P资源共享问题 实现用户权限列表一般用什么表示?用listvieW?还是datagridvieW? 如何复制粘贴 如何用C#得到sql server 数据库的函数名呢?并通过程序去增,删,修改函数? 经常看到网站上:您当前的位置为:这种是怎么做的? 求一个C#读取数据库的问题 关于WMS9多媒体插件SDK的问题 加了 static到底有什么影响,什么时候用 PropertyGrid组件 弹出一个Form 紧急求助 C# 如何获取操作系统的信息 在项目开发中,什么情况下才会用abstract抽象类?谢谢!!!
{
if (ctr.Name =="radioButton3")
{
((RadioButton)ctr).Checked = true;
}
}
{
if (ctr.ClientID == "RadioButton2")
{
((RadioButton)ctr).Checked = true;
}
}
a=(System.Web.UI.WebControls.Image)Page.FindControl(strTableName.ToLower());
if(a==null)
{
//没有找到该控件,则屏蔽该错误
}
else
{
//a.ID=strTableName;
a.ImageUrl="../a.jpg";
}
if(myControl1!=null)
{
// Get control's parent.
Control myControl2 = myControl1.Parent;
Response.Write("Parent of the text box is : " + myControl2.ID);
}
else
{
Response.Write("Control not found");
}