C# dropdownlist中的字符串包含<;在itextshpar

C# dropdownlist中的字符串包含<;在itextshpar,c#,drop-down-menu,special-characters,asp.net-mvc-5,C#,Drop Down Menu,Special Characters,Asp.net Mvc 5,我的应用程序是MVC5,我从dropdownlist中得到一个字符串值,项目值是我认为使用它可以解决您的问题 string itemvalue = x; /*item value from the dropdownlist*/ string totalvalue = String.Format( "score{0}",x); 为什么不是这个 从字符串中删除% String.Format( "score{0}%",x); 或 我使用了HttpUtility.HtmlEncode(totalv

我的应用程序是MVC5,我从dropdownlist中得到一个字符串值,项目值是我认为使用它可以解决您的问题

string itemvalue = x; /*item value from the dropdownlist*/
string totalvalue = String.Format( "score{0}",x);
为什么不是这个 从字符串中删除
%

 String.Format( "score{0}%",x);

我使用了HttpUtility.HtmlEncode(totalvalue),有效。

代码是一个html标记。您可以将其替换为code/code/p 预破坏项值=x/*下拉列表中的项目值*/ 字符串totalvalue=“分数”+x; totalvalue.Replace(“,”); //你现在可以用了!;) /编码/预编码 更糟的事情: 代码>应为


请参阅

在将<符号发射回浏览器之前是否要对其进行转义?如何在iTextSharp中创建字符串?您是在手动创建
区块
短语
还是
段落
?您是使用
HTMLWorker
还是
XMLWorker
解析HTML?另外,您使用的是什么版本的iTextSharp?我使用的是HTMLWorker。谢谢谢谢我认为问题出在itextsharp HTMLWorker。谢谢,无法解决替换;我使用了HttpUtility.HtmlEncode。它应该被替换。耶!我只是从我的想象中编码出来的!:我改了。
 String.Format( "score{0}%",x);
 String.Format( "score{0:00%}",x);
string itemvalue = x; /*item value from the dropdownlist*/
string totalvalue = "score" + x;
totalvalue.Replace("<","&lt;");
// you can use it now! ;)