欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

動態(tài)向頁面添加控件和使用正則表達式的代碼

 更新時間:2009年08月13日 14:54:34   作者:  
動態(tài)向頁面添加控件和使用正則表達式的實現(xiàn)代碼。
復(fù)制代碼 代碼如下:

namespace WebCode
{
public partial class _default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
String str = "這是一個測試文件<{config name=\"pagetitle1\"}>,一個標(biāo)簽的解析<{config name=\"pagetitle2\" count=\"2\"}>過程";
Label mylabel = new Label();
mylabel.ID = "display";
mylabel.Text = this.myReplace(str);
Page.Form.Controls.Add(mylabel);
}
protected String myReplace(String str)
{
String pattern = @"\<\{(.*?)\}\>";
Regex p = new Regex(pattern, RegexOptions.IgnoreCase);
MatchCollection m = p.Matches(str);
String matchs = "";
for (int i = 0; i < m.Count; i++)
{
matchs += "," + m[i];
}
return matchs.Substring(1);
}
}
}

Page.Form.Controls.Add
向頁面中Form節(jié)點的尾部添加控件。
using System.Text.RegularExpressions;
使用正則表達式要使用的類

相關(guān)文章

最新評論