简体   繁体   中英

ASP.NET C# TagBuilder SetInnerText rendered %20 on whitespace

Please help me figure it out on this code, i want to build Common Html using TagBuilder with this code.

var href = new TagBuilder("a");
href.MergeAttribute("href", "#");
href.SetInnerText(item); <== This part rendered eg. "Just%20Test" but my text "Just Test"

i need your help to show "Just Test" because my text has white space. i already try with Regular Expression but in my page always display like that if have white space.

Thank's in advice, and really sorry for my poor English.

Try using

href.InnertHtml = item;

in stead. According to the documentation , this will set the inner text without HTML encoding it first.

The funny thing is HTML encoding doesn't encode spaces... but I'm guessing there is more to the problem than your description. This might provide us with more information.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM