displaying text without the html tags showing up

4 posts, 1 answers
  1. Bryan Davis
    Bryan Davis avatar
    24 posts
    Member since:
    Jan 2008

    Posted 08 Sep 2009 Link to this post

    Hello, I am having a problem with the radtext editor....  I am inserting the text from the radeditor into a sql table.  When I insert it the record in the db contains everything including the html tags. 
    <span style="text-decoration: underline">this is a test.</span><br /><br /><span style="text-decoration: underline">this is another test.</span><br /><br />

    My problem is when I try to pull that data back into any kindof of gridview, data repeater, datalist, it pulls all the tags as well.  I need to some how pull all the data into my ContentPlaceHolder1 and have it formatted like it was in the editor.  I have seen this done in classic asp, where the data is pulled straight from the sql table into an html table and then all the formating does what its suppose to do.  I am using asp.net though.  I have an update page with my rad editor and a display page for the results.  Can anybody help me out here?

    Thank you

     

  2. Answer
    ManniAT
    ManniAT avatar
    877 posts
    Member since:
    Nov 2003

    Posted 08 Sep 2009 Link to this post

    Hi Brian,

    I'm not sure if I understand you correctly - but we'll figure out what's going on.
    First of all - you have a RadEditor bound to a nvarcher(XXX) column in a database.
    Something like this:
    Snippet created with CBEnhancer

    <b>Content:</b><br />
        <telerik:RadEditor Content='<%# Bind("TheContent") %>' Skin="Office2007" ID="edContent" runat="server"
        ToolsFile="~/

    In the data you have now code like
    <span style="text-decoration: underline">this is a test.</span><br />
    This seems OK so far (the text should be underlined I guess).
    So the editor does what it should - it gives you the correct data.
    To display this data you now have to pull out your SQL data an place it somewhere on your page.
    Now the question - how do you do this?
    The correct code would be something like:
    <%# Eval("TheContent") %>

    Anyhow - what you get (I guess) is not formatted text - instead you get HTML source.
    If so - you are possibly binding your data to a "text" property of some control.
    Instead you should bind it to "InnerHTML".
    RadGridView has no problem with such data. A GridBoundColumn does the job.
    If you use a repeater or something like this - use the code I showed above (Eval....)
    If you do it in code behind - look for a control which offers "InnerHTML" and not only Text.
    An example for code behind - use a div like this:
    Snippet created with CBEnhancer
    <div id="diContent" runat="server"></div>
    And in code do:
    Snippet created with CBEnhancer
        diContent.InnerHtml = GetContent();
    }

    I also made a sample about using RadEditor to store / retrieve data from a database - maybe this can help also:
    http://www.telerik.com/community/code-library/aspnet-ajax/general/a-15-minute-cms-using-radgrid-and-radeditor.aspx

    Regards
    Manfred
    PS: if this post was helpful please use "Mark as answer"
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Bryan Davis
    Bryan Davis avatar
    24 posts
    Member since:
    Jan 2008

    Posted 09 Sep 2009 Link to this post

    Thanks for the help ManniAT.  I added a radgrid binded it to my datasource and it displayed my data in the correct format.
    This is a test

    This is another one....

    and another one..  

    The only problem I have now is how to clear the radgrid of its skin.  With the asp.net grid all I had to do is select remove formatting and tell it to....

    GridView1.GridLines = GridLines.None

    GridView1.HeaderRow.Visible =

    False

     

    on the server side.

    Thanks again for the help.

  5. ManniAT
    ManniAT avatar
    877 posts
    Member since:
    Nov 2003

    Posted 09 Sep 2009 Link to this post

    Hi,

    what's your desired result?
    Not "table like datadisplay" I guess - because you want to remove the "visual representation" of the grid.
    The databinding should also work with other bindable controls like the good old
    DataRepeater or FormView / DetailsView.

    Or you can bind from code behind like I did in my example I linked above.

    If you could provide a bit more information about the desired result maybe I can help you better.
    I know you want to display the text from the database - but how?
    One record per page? Several records on one page? One record per selection....

    Regards
    Manfred
Back to Top