脚本 var a=document.GetElementByTag("DropDownList");
public static Control GetPostBackControl(Page page) ...{ Control control = null; string ctrlname = page.Request.Params.Get("__EVENTTARGET"); if (ctrlname != null && ctrlname != string.Empty) ...{ control = page.FindControl(ctrlname); } else ...{ foreach (string ctl in page.Request.Form) ...{ Control ddl = page.FindControl(ctl); if (ddl is System.Web.UI.WebControls.DropDownList) ...{ control = c; break; } } } return control; }
foreach (Control ctrl in this.Page.Controls) { foreach (Control ctl in ctrl.Controls) { if (ctl.GetType().Name == "DropDownList") { DropDownList dr = new DropDownList(); dr = (DropDownList)this.FindControl(ctl.ID); dr.Items.Add(new ListItem("0", "请选择3")); }
} }修改下就可以
foreach (Control myCl in this.Page.Controls) { if (myCl.GetType().ToString() == "System.Web.UI.WebControls.DropDownList") { //do something } }
DDLArray[]=document.GetElementByTag("### ")
...{
Control control = null; string ctrlname = page.Request.Params.Get("__EVENTTARGET");
if (ctrlname != null && ctrlname != string.Empty)
...{
control = page.FindControl(ctrlname);
}
else
...{
foreach (string ctl in page.Request.Form)
...{
Control ddl = page.FindControl(ctl);
if (ddl is System.Web.UI.WebControls.DropDownList)
...{
control = c;
break;
}
}
}
return control;
}
foreach (Control ctrl in this.Page.Controls)
{
foreach (Control ctl in ctrl.Controls)
{
if (ctl.GetType().Name == "DropDownList")
{
DropDownList dr = new DropDownList();
dr = (DropDownList)this.FindControl(ctl.ID);
dr.Items.Add(new ListItem("0", "请选择3"));
}
}
}修改下就可以
foreach (Control myCl in this.Page.Controls)
{
if (myCl.GetType().ToString() == "System.Web.UI.WebControls.DropDownList")
{
//do something
}
}