static public void UnwrapControl(System.Web.UI.Page pgUnwrap, String strUnwrap) { Regex r3 = new Regex("(&&&)"); // Split on hyphens. Regex r2 = new Regex("(&&)"); // Split on hyphens. Regex r1 = new Regex("(&)"); // Split on hyphens. String[] sa3, sa2, sa1; String s3, s2, s1; int i3, i2, i1; String strId, strTagName; System.Web.UI.Control ctrlUnwrap; DropDownList ddlUnwrap; ListItem liAdd;
s3 = strUnwrap; sa3 = r3.Split(s3);
for(i3=0;i3<(sa3.Length+1)/2;i3++) { s2 = sa3[i3*2]; if(s2.Length>0) { sa2 = r2.Split(s2); if(sa2.Length>1) { s1 = sa2[0]; sa1 = r1.Split(s1); if(sa1.Length==3) { strId = sa1[0]; strTagName = sa1[2]; ctrlUnwrap = pgUnwrap.FindControl(strId); if(ctrlUnwrap !=null) { if(strTagName == "SELECT") { ddlUnwrap = (DropDownList)ctrlUnwrap; ddlUnwrap.Items.Clear();
for(i2=1; i2 < (sa2.Length+1)/2;i2++) { s1 = sa2[i2*2]; sa1 = r1.Split(s1); liAdd = new System.Web.UI.WebControls.ListItem(sa1[4],sa1[2]); ddlUnwrap.Items.Add(liAdd); } } } } } } } }
(出处:清风网络学院)
上一篇:ASP教程
下一篇:使用正则表达式实现模式图片新闻.ASP
|