1 通用代码:
public static ArrayList BtnList(System.Web.UI.Control page) ...{ int nPageControls = page.Controls.Count; ArrayList btnText = new ArrayList(); for (int i = 0; i < nPageControls; i++) ...{ foreach (System.Web.UI.Control control in page.Controls[i].Controls) ...{ if (control is Button) ...{ //btnText.Add(control.ID); btnText.Add((control as Button).Text); } } } return btnText; }
2 页面调用代码
protected void Page_Load(object sender, EventArgs e) ...{ ArrayList arrayList = new ArrayList(); System.Web.UI.Page page1 = (System.Web.UI.Page)HttpContext.Current.Handler; arrayList = BtnCtrList.BtnList(page1); foreach (object o in arrayList) ...{ ListBox1.Items.Add(o.ToString()); } }
以上是小编为您精心准备的的内容,在的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索web
, arraylist
, system
, control
, Page.Controls
Controls
,以便于您获取更多的相关知识。
时间: 2024-11-29 01:51:56