用户名:
密 码: 记住
您当前的位置:首页 > 网络编程 > Net教程

动态向页面添加控件和使用正则表达式的代码

时间:2015-01-29  来源:互联网  作者:佚名
复制代码 代码如下:
namespace WebCode
{
public partial class _default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
String str = "这是一个测试文件<{config name=\"pagetitle1\"}>,一个标签的解析<{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节点的尾部添加控件。
using System.Text.RegularExpressions;
使用正则表达式要使用的类
来顶一下
返回首页
返回首页
推荐资讯
asp.net 简单验证码验证实现代码 asp.net 简单验证码验证实现代码首先是新建一个验证码页面 ValidateCode.aspx 定义变量 这样
通过ASP.net实现flash对数据库的访问 通过ASP.net实现flash对数据库的访环境:adobe flash CS4,VS2008 , Access2003 实现步骤: 1
相关文章
栏目更新
栏目热门