这是后台代码
代码
using System
using System Collections
using System Configuration
using System Data
using System Linq
using System Web
using System Web Security
using System Web UI
using System Web UI HtmlControls
using System Web UI WebControls
using System Web UI WebControls WebParts
using System Xml Linq
using System Text
using System Text RegularExpressions
namespace WebApplication {
public partial class _Default : System Web UI Page {
protected void Page_Load(object sender EventArgs e) {
String str = <a href=\ {&a >\ >{&a }<a>{&bbbbccccc }
String b = cleanStr(str)
string c = str (str)
this Label Text = c
}
public string cleanStr(String str) {
StringBuilder bs = new StringBuilder(str)
string str = str Substring( str Length )
str = str Trim()
return str
}
public string str (string str) {
int i =
int i =
string str_ =
string str =
string str =
Boolean bl = false
Boolean bl = true
for (int i = i <str Lengthi++) {
if (str[i] == { &&str[i + ] == &) {
i = i
bl = true
bl = false
}
if (bl ) {
str_ += str[i]
}
if (str[i] == } &&bl ) {
i = i
str = str Substring(i (i i ) + )// +
str = str Substring( str Length )
str = str Trim()
str = _str(str )
str_ += str
bl = false
bl = true
}
}
return str_
}
public string _str(string str) {
if (str == a ) {
return _str ( {&b} )
}
if (str == b ) {
return _str ( {&c} )
}
if (str == c ) {
return _str ( 进入qq )
}
return null
}
public string _str (string str) {
Regex r = new Regex(@ {+&+[A Za z ]+} )
if (r IsMatch(str)) {
return str (str)
}
return str
}
}
}
前台代码
代码
<%@ Page Language= C# AutoEventWireup= true CodeBehind= Default aspx cs Inherits= WebApplication _Default %>
<!DOCTYPE PUBLIC //W C//DTD XHTML Transitional//EN transitional dtd >
<xmlns= >
<head id= Head runat= server >
<title>Untitled Page</title>
</head>
<body>
<form id= form runat= server >
<div>
<asp:Label ID= Label runat= server ></asp:Label>
</div>
</form>
</body>
</>
运行结果
lishixinzhi/Article/program/net/201311/11752原则上不可以自定义标签。
但HTML是宽松语言,要求并不严格,即使发生错误也能正常显示。自定义标签大部分浏览器也可以正常显示,不过还是建议xhtml。这个是可拓展的html,支持自己写
就是自己定义一些标签啊,然后获取那些标签,就像div,div是微软官方定义的,你也可以自己定义xxx 标签, 然后<xxxx:这个是标签></xxx:这个是自定义标签>这个就是你自己定义的标签,然后获取修饰就是xxx\:自定义标签{boder:xxx;padingxxx;},但是要在头文件里面写明白,不建议涉入。