2011-10-15 29 views
2

使用和不使用Server.HtmlDecode()有什麼區別?什麼是Server.HtmlEncode()?

例如:

txtLocation.Text = Server.HtmlDecode(awardShowYear.ShowLocation); 
txtLocation.Text = awardShowYear.ShowLocation; 

是什麼的代碼這兩條線之間的差異?

+0

ShowLocation是否保存HTML?或者一個原始字符串? –

回答

3

第一招:

txtLocation.Text = Server.HtmlDecode(awardShowYear.ShowLocation); 

將從字符串中刪除任何HTML編碼並分配解碼結果到txtLocation.Text。

第二個:

txtLocation.Text = awardShowYear.ShowLocation; 

將簡單地分配字符串txtLocation.Text,保留任何HTML編碼,它是存在的。

請參閱HttpServerUtility.HtmlDecode Method (String)

+0

thnxs man ......... – user993634