欢迎来到开源之家!织梦模板,dede模板下载,织梦cms模板,免费网站模板下载站

开源之家

ASP.NET 中的 HTML 编码

企业模板

导 读:server.htmlencode 和 server.urlencode 是asp中非常常见的函数,在asp.net中也有类似的函数:htmlencode 和 urlencode (注意大小写)以下用实例来进行介绍。
server.htmlencode and server.urlencode are very common functions used by asp developers. well, as you may have guessed, these two functions have asp.net counterparts. htmlencode and urlencode (notice case) are part of the system.web.httputility namespace.
here is the demo
urlencode.asp?test=1&test1=2
urlencode.asp%3ftest%3d1%26test1%3d2

this is a test & hopefully it works!
<h1>this is a test & hopefully it works!</h1>
**********************************
here is the code:
**********************************
<%@ page language="vb" %>
<%@ import namespace="system.web.httputility" %>
<html>
<head>
<title>htmlencode and urlencode the asp.net way</title>
<script language="vb" runat="server">
sub page_load(sender as object, e as eventargs)
assign our test url to a variable, assign the variable to our
label control
dim strurltext as string = "urlencode.asp?test=1&test1=2"
strurl.text = strurltext
encode the test url, assign it to a variable, assign the
variable to our label control
dim strurlencodetext as string = urlencode(strurltext)
strurlencode.text = strurlencodetext
assign our test url to a variable, assign the variable to our
label control
dim strhtmltext as string = "<h1>this is a test & hopefully it
works!</h1>"
strhtml.text = strhtmltext
encode the test html, assign it to a variable, assign the
variable to our label control
dim strhtmlencodetext as string = htmlencode(strhtmltext)
strhtmlencode.text = strhtmlencodetext
end sub
</script>
</head>
<body>
<asp:label id="strurl" forecolor="red" font-bold="true" runat=server/>
<p>
<asp:label id="strurlencode" forecolor="blue" font-bold="true" runat=server/>
<p>
<asp:label id="strhtml" forecolor="red" font-bold="true" runat=server/>
<p>
<asp:label id="strhtmlencode" forecolor="blue" font-bold="true" runat=server/>

</body>
</html>ASP.NET 中的 HTML 编码


希望以上内容可以解决您的问题!
如有其他问题欢迎大家一起交流学习!
作者:酱油妹 来源:www.srgoc.cn 关注: 时间:2022-05-19 06:00
版权声明:凡注明来源为http://www.109f.cn的均为本站原创,转载请注明来源。
本文网址:http://www.109f.cn/HTML/HTMLjichu/20220519/14029.html
凡本站提供教程均已验证教程的准确性。
相关教程
在线客服

织梦模板 整站模板 新手教程 使用技巧