rt

解决方案 »

  1.   

    foreach (Control ctr in this.Controls)
                {
                    if (ctr.Name =="radioButton3")
                    {
                        ((RadioButton)ctr).Checked = true;
                    }
                }
      

  2.   

    谢谢如果是在aspx页里呢?怎样获得控制权?
      

  3.   

    不好意思,这几天外出了,没有时间上网..今天才看见..如果是aspx页面,也大同小异,不过在web里,控件没有"name"属性,用ClientID替代即可...foreach (Control ctr in this.Panel1 .Controls)
            {
                if (ctr.ClientID == "RadioButton2")
                {
                    ((RadioButton)ctr).Checked = true;
                }
            }
      

  4.   

    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";
             }
      

  5.   

    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");
          }