html编码&解码问题 [英] html Encode & Decode problem

查看:159
本文介绍了html编码&解码问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编码

string strCode = Server.HtmlEncode(this.txtSubject.Text);

点击查看照片



它存储在数据库中的内容

点击查看照片



解码

this.Label1.Text = dr [dcmh_situation]。ToString();

点击照片



如果我使用Server.HtmlDecode(dr [dcmh_situation],则显示任何内容.ToString());

它能够显示原始格式,如果我把它们放在带有多行的文本框中。



所以问题是,它是否能以正确的格式显示(使用Label控件参考第一张照片?

Encode
string strCode = Server.HtmlEncode(this.txtSubject.Text);
click for photo

What it store in database
click for photo

Decode
this.Label1.Text = dr["dcmh_situation"].ToString();
click for photo

it displays nothing if i use Server.HtmlDecode(dr["dcmh_situation"].ToString());
it able to displays the original format if i put them inside the textbox with multiple line.

so the question is, can it be shows in the correct format(refer first photo)with Label control?

推荐答案





您是否尝试过使用URL编码Server.HtmlEncode()。



Hi,

Did you tried using URL encode instead of Server.HtmlEncode().

URL Encoding Functions

In JavaScript, PHP, and ASP there are functions that can be used to URL encode a string.

In JavaScript you can use the encodeURI() function. PHP has the rawurlencode() function and ASP has the Server.URLEncode() function.



请看这个网站:



编码 [ ^ ]



注意:JavaScript函数将空格编码为%20。



谢谢!


Please look at this site:

Encoding[^]

Note: The JavaScript function encodes space as %20.

Thanks!


这篇关于html编码&解码问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆