locked
Invalid chars in the source code of the web page RRS feed

  • Question

  • User-631179455 posted

    Hello,

    I am retrieving the string data from a database SQL Server 2008 EE to a web page created by ASP.NET MVC (language C#). In that text are symbols like í,ú,á... The text is displayed in the web browser correctly but when I look at the source code of that page instead of chars like í ú á is there í ú á.

    How can I have in the source code symbols like í, ú, á instead of í ú á?

    Thanks for helping.

     

    Monday, May 9, 2011 6:24 AM

Answers

  • User-631179455 posted

    Can anybody help me with my problem when I use HtmlHelper DropDownListFor method and I don't want to encode the output in the source code? In the rendered page is everything OK but the problem is in the source code of this page - more in my previous comment.

    UPDATE: I my another forum user "nobdy" wrote:

    Hi,

    I dont thing this is a problem at all. we do encode these symbols for best pracatice and thats what W3C rules say. Browser renders these codes to symbols and display it.

    e.g.

    White Space :  

    > : >

    < : &lt;

    So dont worry, this will not hurt your seo.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, May 10, 2011 1:44 AM

All replies

  • User94409692 posted

    Hi, You can use the Server.HtmlEncode (or) Server.HtmlDecode methods to encode (or) decode the html respectively.

    Monday, May 9, 2011 6:45 AM
  • User-631179455 posted

    Hi,

    thanks for answer but it's not solution of my problem. The output from the database on my web page is rendered OK (I can see á, í...) but when I look at the source code of this page in IE9 or Mozilla Firefox 4, instead of á, í.. I see this: &#237; &#250; and I would like to have the symbols like á, í also in the source code due the SEO optimization.

     

    Monday, May 9, 2011 7:45 AM
  • User-33420011 posted

    use @Html.Raw(....) in view to render properly

    Monday, May 9, 2011 7:54 AM
  • User-631179455 posted
    Thanks for answer that helps me!
    But I don't know how to use that helper method (@Html.Raw) when I use another helper method to generate html output.
    For example I use this:
     
    @Html.DropDownList(
    "CategoryId", (SelectList)(ViewData["CategoriesList"]),"Select Category")
     

    In the source code there is still problem with symbols like &#237; instead of symbol í...

    Is there any possibility to use Raw method for that or any other solution?

    Thanks for help.

    Monday, May 9, 2011 9:22 AM
  • User-631179455 posted

    Can anybody help me with my problem when I use HtmlHelper DropDownListFor method and I don't want to encode the output in the source code? In the rendered page is everything OK but the problem is in the source code of this page - more in my previous comment.

    UPDATE: I my another forum user "nobdy" wrote:

    Hi,

    I dont thing this is a problem at all. we do encode these symbols for best pracatice and thats what W3C rules say. Browser renders these codes to symbols and display it.

    e.g.

    White Space : &nbsp;

    > : &gt;

    < : &lt;

    So dont worry, this will not hurt your seo.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, May 10, 2011 1:44 AM