foreach (Control obj in this.Controls[1].Controls)
{
 if (obj is System.Web.UI.WebControls.Button)
 {
  Response.Write(((Button)obj).Text);
 }
}try it.

解决方案 »

  1.   

    to icyer()
    谢谢你,但好像还是没用阿
    你的代码没有输出
      

  2.   

    如果你的Button不是直接包含在Form中的话(不如是Panel的子控件),就不能直接找到。
    可以通过递归来遍历:
    private void GetSubControl(Control obj)
    {
    foreach (Control c in obj.Controls)
    {
    if (c is Button)
    {
    Response.Write(((Button)c).ID + "<br>");
    }
    if (c.Controls.Count > 0)
    {
    this.GetSubControl(c);
    }
    }
    }
    调用:
    this.GetSubControl(this);不知道这个方法是不是有点笨。
      

  3.   

    <form id="MAlermDigest" method="post" runat="server">

    <table id="Table6" width="984" runat="server">
    <tr id="Tr8" runat="server">
    <td align="left" runat="server" ID="Td19">
    <INPUT type="button" value="閉じる" onclick="javascript:self.close()"><A onclick="javascript:window.history.back();" href="#">戻る</A>
    </td>
    <td id="Td21" runat="server" align="right">
    <asp:button id="Button5" runat="server" Width="119px" Text="品目アラーム明細"></asp:button>&nbsp;
    <asp:button id="Button6" runat="server" Width="121px" Text="欠品アラーム明細"></asp:button>&nbsp;
    <asp:button id="Button4" runat="server" Width="135px" Text="使用先アラーム明細"></asp:button>&nbsp;
    <asp:button id="Button7" runat="server" Width="125px" Text="使用先別余剰在庫 "></asp:button>
    </td>
    </tr>
    </table>
    </form>应该没有包含在form中
    谢谢 icyer() ,again
      

  4.   

    分明是包含在<table>中的嘛,用那个递归的函数可以得到呀。
      

  5.   

    为了设置button的字体,去遍历页面的button,这种方法是不是有点笨呀?
    你完全可以为这些button写一个css style。