Can anyone help me get FCKeditor working with a Access database in an ASP.NET environment.
I’m using master pages and have FCKeditor install and working.
Just have no idea how to get the data into the editor and then save it back.
This is what I have so far (taken from another editor that doesn’t give me the right output)
Thanks for any help.
---- PageEditor.aspx ----
<%@ Page Language="VB" MasterPageFile="~/Admin/Admin.master" AutoEventWireup="false" CodeFile="PageEditor.aspx.vb" Inherits="FredCK.FCKeditorV2.Admin_PageEditor" title="Untitled Page" %>
<%@ Register Assembly="FredCK.FCKeditorV2" Namespace="FredCK.FCKeditorV2" TagPrefix="FCKeditorV2" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<FCKeditorV2:FCKeditor ID="fckeditor" runat="server" BasePath="~/Admin/FCKeditor/">
</FCKeditorV2:FCKeditor>
</asp:Content>
---- PageEditor.aspx.vb ----
Option Explicit On
Option Strict On
Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.Data
Imports System.Data.OleDb
Imports System.Drawing
Imports System.Web
Imports System.Web.SessionState
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Imports FredCK.FCKeditorV2
Namespace FredCK.FCKeditorV2
Public Class Admin_PageEditor
Inherits System.Web.UI.Page
Public Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim myConn As New OleDbConnection()
Dim sqlString As String
myConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='|DataDirectory|\db.mdb';Persist Security Info=True"
myConn.Open()
If Page.IsPostBack Then
Dim myComm As OleDbCommand
sqlString = "UPDATE Pages SET pageText=? WHERE pageID='home'"
myComm = New OleDbCommand(sqlString, myConn)
myComm.Parameters.Add(New OleDbParameter("@pageText", OleDbType.VarChar))
myComm.Parameters("@pageText").Value = fckeditor.Value
myComm.ExecuteNonQuery()
Else
sqlString = "SELECT pageText FROM Pages WHERE pageID='home'"
Dim eAdapter As New OleDbDataAdapter(sqlString, myConn)
Dim eTable As New DataTable()
Dim CommandBuilder As New OleDbCommandBuilder(eAdapter)
eAdapter.Fill(eTable)
fckeditor.Value() = CStr(eTable.Rows(0)(0))
eAdapter.Dispose()
eTable.Dispose()
End If
myConn.Close()
myConn.Dispose()
End Sub
End Class
End Namespace
I’m using master pages and have FCKeditor install and working.
Just have no idea how to get the data into the editor and then save it back.
This is what I have so far (taken from another editor that doesn’t give me the right output)
Thanks for any help.
---- PageEditor.aspx ----
<%@ Page Language="VB" MasterPageFile="~/Admin/Admin.master" AutoEventWireup="false" CodeFile="PageEditor.aspx.vb" Inherits="FredCK.FCKeditorV2.Admin_PageEditor" title="Untitled Page" %>
<%@ Register Assembly="FredCK.FCKeditorV2" Namespace="FredCK.FCKeditorV2" TagPrefix="FCKeditorV2" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<FCKeditorV2:FCKeditor ID="fckeditor" runat="server" BasePath="~/Admin/FCKeditor/">
</FCKeditorV2:FCKeditor>
</asp:Content>
---- PageEditor.aspx.vb ----
Option Explicit On
Option Strict On
Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.Data
Imports System.Data.OleDb
Imports System.Drawing
Imports System.Web
Imports System.Web.SessionState
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Imports FredCK.FCKeditorV2
Namespace FredCK.FCKeditorV2
Public Class Admin_PageEditor
Inherits System.Web.UI.Page
Public Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim myConn As New OleDbConnection()
Dim sqlString As String
myConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='|DataDirectory|\db.mdb';Persist Security Info=True"
myConn.Open()
If Page.IsPostBack Then
Dim myComm As OleDbCommand
sqlString = "UPDATE Pages SET pageText=? WHERE pageID='home'"
myComm = New OleDbCommand(sqlString, myConn)
myComm.Parameters.Add(New OleDbParameter("@pageText", OleDbType.VarChar))
myComm.Parameters("@pageText").Value = fckeditor.Value
myComm.ExecuteNonQuery()
Else
sqlString = "SELECT pageText FROM Pages WHERE pageID='home'"
Dim eAdapter As New OleDbDataAdapter(sqlString, myConn)
Dim eTable As New DataTable()
Dim CommandBuilder As New OleDbCommandBuilder(eAdapter)
eAdapter.Fill(eTable)
fckeditor.Value() = CStr(eTable.Rows(0)(0))
eAdapter.Dispose()
eTable.Dispose()
End If
myConn.Close()
myConn.Dispose()
End Sub
End Class
End Namespace