HTML Output Databinding

Last post 07-23-2008, 9:10 AM by MarkMyWords. 3 replies.
Sort Posts: Previous Next
  •  07-20-2008, 4:25 PM 42379

    HTML Output Databinding

    Hello.  I have an ASPX website.  I have a FormControl for adding an entry into a database.  I need to use the Cute Editor for adding HTML to a cell in the database, but I can't figure out whic property to bind the database to.  Do I need to do something else that is not binding to get the HTML into the cell.  If more explination is needed, please post so.  Thanks!  I am using .net Framework 3.5, Microsoft Visual Web Developer 2008, and SQL Server Express.
     
    Esentially what I am trying to ask is how do you get the HTML that the editor generates when you click on the "HTML" at the bottom into a textbox or a database cell.
  •  07-20-2008, 9:19 PM 42382 in reply to 42379

    Re: HTML Output Databinding

    kjkramer,
     
    Please use the following property:

    Editor.Text Property

    This property provides access to the text within the editable area of the CuteEditor control. It can be used to set the text when the control is first displayed and also to read out the text when a form has been submitted.
     
    Demo:
     

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  07-22-2008, 11:26 PM 42455 in reply to 42379

    Re: HTML Output Databinding

    Thanks for the response, but I already tried that.  I databind it, but it does not put anything in the database on insert.  Does the column in the database need to be formatted something else then "text"?  Does there need to be a format for the databind?  It is weired that it is not working.
     
    Thanks in advance.
  •  07-23-2008, 9:10 AM 42470 in reply to 42379

    Re: HTML Output Databinding

     
    I have not tried databinding automatically, but you could easily push the data around using the Edtiro1.Text property as Adam points out...
     
    C# Code Example 
     
    // post the following into your ASPX page inside <% %> or in the page_load call in the code-behind.  This is really a mickey-mouse example but hopefully it gives you an idea of what to do.  When you click the SAVE button in the editor, the page will post back and the html is retreived from the Editor1.Text propery.
     
    if (Page.IsPostBack)
    {
      // Create database connection (conn string is an example here)
      System.Data.SqlClient.SqlConnection conn
              =
    new System.Data.SqlClient.SqlConnection(@"Sever=(local)\SQLEXPRESS; Database=Blah");
      conn.Open();
      // Create command
      System.Data.SqlClient.SqlCommand sql = new System.Data.SqlClient.SqlCommand("spInsertHtml", conn);
      sql.CommandType = System.Data.
    CommandType.StoredProcedure;
      sql.Connection = conn;
      // Set editor html to parameter
      System.Data.SqlClient.SqlParameter param1 = new System.Data.SqlClient.SqlParameter();
      param1.ParameterName =
    "@HTML";
      param1.SqlDbType = System.Data.
    SqlDbType.Text;
      param1.Value = Editor1.Text;
      sql.Parameters.Add(param1);
      // Run query
      string id = sql.ExecuteScalar().ToString();
      // Close connection
      conn.Close();
    }
     
    SQL Server Stored Procedure Used in the above
     
      

    CREATE PROCEDURE spInsertHtml @HTML TEXT
    AS

    -- Insert HTML into table, merely and example here
    INSERT INTO MY_HTML_TABLE
    (
        HTML
    )
    VALUES
    (
        @HTML
    )
    -- Return Identity from new table row
    SELECT @@IDENTITY

View as RSS news feed in XML