Quantcast
Channel: SQL Server Database Engine forum
Viewing all articles
Browse latest Browse all 15264

Problem with HTML editor databinding

$
0
0

Hello there,

First up thanks to all the guys who have posted great solutions to common problems which helped me out many times in the past. Now I have got a problem of my own.  I am using this third party HTML editor called obout HTML editor.  I have linked my page to a SQL server table named tbtHome containing to fields.  fldcontent(nvarchar(max) and ID). While I can retreive the existing data in the database, I am not able to save any changes made using the update command. Me thinks there might be something wrong with my update command but it does not throw any exception or error so I don't know what to do. I've been at it for two days now without much progress. I really hope some one can help. Here's my code

<asp:Button ID="Button1" runat="server" Text="Edit" /><br /><asp:Label ID="content" runat="server" Text="Label"></asp:Label><asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager><obout:Editor ID="editor" runat="server"  PopupHolderID ="popupHolder" Visible ="true"><TopToolbar><AddButtons><custom:ImmediateImageInsert  ID="ImmediateImageInsert1" runat="server"/></AddButtons></TopToolbar></obout:Editor><asp:Button ID="Button2" runat="server" Text="Save" OnClientClick="Button2_Click" /></div><asp:Label ID="exmsg" runat="server" Text="Label"></asp:Label>


Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.Control
Imports System.Data
Imports System.Data.SqlClient
Imports System.Security
Imports System.Security.Authentication
Imports Obout
Imports OboutInc



Partial Class Home
    Inherits System.Web.UI.Page


    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim Connection As New SqlConnection


        Dim dr As SqlDataReader
        Dim Command As SqlCommand
        Connection = New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\CMS.mdf;Integrated Security=True;User Instance=True")
        Connection.Open()
        Command = New SqlCommand("Select TOP 1 fldcontent from tbtHome ", Connection)
        dr = Command.ExecuteReader()
        Try
            While dr.Read()
                editor.Content = dr("fldcontent")
                content.Text = dr("fldcontent")
            End While
        Catch Ex As Exception
            exmsg.Text = Ex.Message
        Finally
            dr.Close()
            Connection.Close()

        End Try
    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

    End Sub

    Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click

        Dim Con As New SqlConnection
        
        Dim Command As SqlCommand

        Con = New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\CMS.mdf;Integrated Security=True;User Instance=True")
        Con.Open()
        Command = New SqlCommand("Update TOP (1) tbtHome set fldcontent = @Richtextbox", Con)
        Command.Parameters.AddWithValue("@Richtextbox", editor.Content)
        Command.ExecuteNonQuery()

        Con.Close()
    End Sub



End Class

Thanks a lot in advance,

Sai.


Viewing all articles
Browse latest Browse all 15264

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>