HTML rendering issue

2 posts, 0 answers
  1. Saeid Kdaimati
    Saeid Kdaimati avatar
    48 posts
    Member since:
    May 2006

    Posted 27 Oct 2014 Link to this post

    Hi,

    I'm using code snippet as follows:
    Title = string.Format("<a class=\"LeadStory\" href=\"/Report/{0}/{1}\"><h1>{2}</h1></a>",
                                ds.Tables[0].Rows[0]["report_id"].ToString(),
                                aaHelper.Text.StripText.UrlTitle(ds.Tables[0].Rows[0]["title"].ToString()),
                                ds.Tables[0].Rows[0]["title"].ToString());
     
                        ReadMore = string.Format("<a class=\"LeadFullReport\" href=\"Report/{0}/{1}\">full report</a>",
                            ds.Tables[0].Rows[0]["report_id"].ToString(),
                            aaHelper.Text.StripText.UrlTitle(ds.Tables[0].Rows[0]["title"].ToString()));
    RadEditor1.Snippets.Add("Lead Title", Title);
                        RadEditor1.Snippets.Add("Full Report", ReadMore);
    When I insert both code snippets, the "Full Report" works correctly, but the problem is with the "Title", where the editor generate it like: <a....></a><h1>....</h1>
    Even when I manually change the code in HTML view then switch back to design view, the editor change the code again.

    I'm using version 2014.2.724.45

    Any idea?
  2. Ianko
    Admin
    Ianko avatar
    1535 posts

    Posted 29 Oct 2014 Link to this post

    Hi Saeid,

    Note that the RadEditor control is designed to be an XHTML editor and all generated HTML should be valid as per to the W3C specifications.

    Nesting block elements (e.g., H[1-6], P, UL etc.) in an inline element (e.g., SPAN, A, FONT etc.) is an invalid scenario and it causes W#C validation to fail. This is why the built-in filters of the RadEditor correct this invalid element nesting and move the block element outside the inline one. You can also examine a related discussion on the topic in this Stackoverflow forum thread.

    I suggest redesigning the HTML created in the snippets to pass the W3C validation. You can also use the built-in W3C dialog titled XHTML Validator for you convenience.

    Regards,
    Ianko
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top