protected void btnbatch_Click(object sender, EventArgs e)
{
    Button btnactual= sender as Button;
    ContentPlaceHolder myContent =
(ContentPlaceHolder)this.Master.FindControl("ContentPlaceHolder1");
}


如何使用for-each在内容占位符中查找控件。我将代码放置在Div tag
但我没有。

谁能帮我吗?

最佳答案

Protected void btnbatch_Click(object sender, EventArgs e)
{

    Button btnactual= sender as Button;
    ContentPlaceHolder myContent =
   (ContentPlaceHolder)this.Master.FindControl("ContentPlaceHolder1");

    foreach (Control ctrl in myContent.FindControl("divBatches").Controls)
    {
        if (ctrl.ID == btnactual.ID)
        {
           //blah blah
        }
     }
  }


试试这个.....

08-04 19:39