in
Forums
Blogs
Files
Devexpress.Com
Client Center
Support Center
DevExpress Channel

Saving HTML in SQL Server

Last post 9/26/2008 11:08 AM by Victor A (Developer Express). 11 replies.
Page 1 of 1 (12 items)
Sort Posts:
Previous Next
  • 9/23/2008 4:10 PM

    Saving HTML in SQL Server

    Once the user has typed in text etc, I want to store that information in my sql server table. Couple of questions:

    (1) There is no ADD button, so im wondering how I can add a button to perform said task. I know you can create a custom toolbar and add the ADD button to the toolbar, but im interested in placing the button on the bottom, below the Design, HTML, Preview tabs. Any way I can do this? Or do i have to code a button outside of the HTMLEditor?

    (2) On an onclick, I want to store that HTML in my SQL Server table. How would I accomplish this? Ive seen your databinding example here, www.devexpress.com/issue=Q101336 and http://demos.devexpress.com/Tutorials/HtmlEditor/HtmlFromDatabase/HtmlFromDatabase.aspx
    but im not following what the actual code is to get the html and store it.

    (3) How do you display this HTML text in an ASPX page? Does DevEx have an IFRAME like control for this purpose?

    thanks

  • 9/24/2008 2:42 AM In reply to

    Re: Saving HTML in SQL Server

    Hi!

    1. It's impossible to place a custom tab beside Design, HTML, Preview tabs. You should create a standalone button.
    2. To store HTML markup to SQL database, use the Html property and SqlDataSource with corresponding InsertCommand and UpdateCommand.
    3. On the client-side, ASPxHtmlEditor uses the IFRAME element for displaying and visual editing the content html.
    Thanks,
    Andrew R

    R&D, ASP.Net Team
    Developer Express Inc.

    PS. If you wish to receive direct assistance from our Support Team, use Support Center at http://www.devexpress.com/Support/Center
  • 9/24/2008 2:30 PM In reply to

    Re: Saving HTML in SQL Server

     1. I didnt mean to say have a custom tab, I meant, would i be able to put a Button under D/H/P tabs but within the HTML editor.

    2. I guess my question was more related towards SQL...would I just store the HTML as nvarchar?

    3. Do you have an example for this...im not sure im following what you mean here.

  • 9/25/2008 2:37 AM In reply to

    Re: Saving HTML in SQL Server

    Hi!

    1. The ASPxHtmlEditor doesn't have the capability to put a Button under Design, HTML, or  Preview tabs.
    2. Store HTML markup to the nvarchar(MAX) type column. Also, you can store the HTML markup obtained from the Html property to the XML type column because this html markup is well-formed.
    3. We have no example demonstrating how to use an IFRAME element for displaying the HTML markup.
    Thanks,
    Andrew R

    R&D, ASP.Net Team
    Developer Express Inc.

    PS. If you wish to receive direct assistance from our Support Team, use Support Center at http://www.devexpress.com/Support/Center
  • 9/25/2008 3:13 PM In reply to

    Re: Saving HTML in SQL Server

     Ok..say I have some html from my ASPxHTMLEditor  (ASPxHtmlEditor1.Html) ...how would I display that html on my web page using any of the DevEx controls.

  • 9/25/2008 4:36 PM In reply to

    Re: Saving HTML in SQL Server

    You can use a ASPxLabel, set it's Text property to the HTML.

    Make sure you have EncodeHTML Set to False on the Label.


    Brien King
    President, ClassicSoft, LLC
    http://www.classicsoft.com
    brien@classicsoft.com
    Developers Helping Developers!

    RM> Ok..say I have some html from my ASPxHTMLEditor
    RM> (ASPxHtmlEditor1.Html) ...how would I display that html on my web
    RM> page using any of the DevEx controls.
    RM>
  • 9/25/2008 5:17 PM In reply to

    Re: Saving HTML in SQL Server

    The label box doesnt allow multilines and display of images etc. I guess I was looking to display the html in more like a textbox like control..maybe ASPxMemo..but I dont see an EncodeHTML property.

  • 9/25/2008 10:32 PM In reply to

    Re: Saving HTML in SQL Server

    Maybe I'm not understanding what you mean. What ever HTML you put in the
    TEXT property of an ASPXLabel should be inserted right into the final document.





    Brien King
    President, ClassicSoft, LLC
    http://www.classicsoft.com
    brien@classicsoft.com
    Developers Helping Developers!

    RM> The label box doesnt allow multilines and display of images etc. I
    RM> guess I was looking to display the html in more like a textbox like
    RM> control..maybe ASPxMemo..but I dont see an EncodeHTML property.
    RM>
  • 9/25/2008 10:57 PM In reply to

    Re: Saving HTML in SQL Server

    Ok, here is a better explanation, sorry if I didnt get my point across earlier, its easy to think something and not know if you arent explaining it correctly.

    Say I have an ASPxHtmlEditor control that users can enter text, images, format the text ..whatever they want to do. Now I have the generated HTML (say. ASPxHtmlEditor1.Html)

    Now I want to display all that content to a user on my web page. How would I display the content, not the actualy markup, but what the markup represents.

    When I used a labelbox with the EncodeHtml set to false, it only seems to display one line, i cant show multilines, and the images and stuff dont appear. Maybe im missing something too.

  • 9/26/2008 2:19 AM In reply to

    Re: Saving HTML in SQL Server

    Hi!

    We suggest two ways for displaying HTML in a web page:

    1. use the ASPxLabel control with the EncodeHtml set to false. There are no problems with displaying a multiline text and images. For example:


      protected
      void Page_Load(object sender, EventArgs e) {       

          ASPxLabel control = new ASPxLabel ();

          control.EncodeHtml = false;

          control.Text = ASPxHtmlEditor1.Html;

          Form.Controls.Add(control);

      }


    2. use the HtmlGenericControl, for example:

        protected void Page_Load(object sender, EventArgs e) {       

            HtmlGenericControl control = new HtmlGenericControl();

            control.InnerHtml = ASPxHtmlEditor1.Html;

            Form.Controls.Add(control);

        }

    Thanks,
    Andrew R

    R&D, ASP.Net Team
    Developer Express Inc.

    PS. If you wish to receive direct assistance from our Support Team, use Support Center at http://www.devexpress.com/Support/Center
  • 9/26/2008 3:08 AM In reply to

    Re: Saving HTML in SQL Server

     hello all,

    sorry for the ignorance, the label control was displaying the html just fine all along.

    I was having an issue with an ASPxMemo control..basically I have a html editor, a memo box and a label. There is also a button and on click I was having the memo and the label populated. The memo was to display the actual HTML and the label the rendered HTML content. I kept getting an error message like so

    A potentially dangerous Request.Form value was detected from the client (ASPxMemo1="<h4>the</h4>
    <p><sp...").

    Description: Request Validation has detected a potentially dangerous client input value, and processing of the request has been aborted. This value may indicate an attempt to compromise the security of your application, such as a cross-site scripting attack. You can disable request validation by setting validateRequest=false in the Page directive or in the configuration section. However, it is strongly recommended that your application explicitly check all inputs in this case.

    Exception Details: System.Web.HttpRequestValidationException: A potentially dangerous Request.Form value was detected from the client (ASPxMemo1="<h4>the</h4>
    <p><sp...").

    Source Error:

    [No relevant source lines]

    and i was associating it to the label box not rendering the html correctly.

    But what was going on was that the memo control sometimes throws the above error if you dont cast the html to string to display the actual markup.

    ie.

    ASPxMemo1.Text = ASPxHtmlEditor1.Html;    <-- may throw the above error on certain instances

    ASPxMemo1.Text = ASPxHtmlEditor1.Html.ToString();      <--- this fixes the above error (i think)

    Thanks all.

  • 9/26/2008 11:08 AM In reply to

    Re: Saving HTML in SQL Server

    Hi,

    ASP.NET doesn't allow you to send HTML-content to the server. I mean,
    if you write some HTML markup into any text editor and send a postback or
    a callback, you'll get a request validation exception.

    To pass markup to the server you must either encode it on the client before
    a postback, or disable request validation for the particular page or for the
    entire site (<pages validateRequest="false" />).

    Victor
    R&D, ASP.NET Team, DevExpress Inc.

    P.S. If you wish to receive direct assistance from our Support Team, use Support Center.
Page 1 of 1 (12 items)
Copyright © 1998-2008 Developer Express Inc.
ALL RIGHTS RESERVED