Cannot access edited data (VB.NET)

Last post 10-19-2006, 1:59 PM by pjoules. 6 replies.
Sort Posts: Previous Next
  •  10-19-2006, 11:24 AM 23702

    Cannot access edited data (VB.NET)

    I have created  a page containing the CuteEditor object and created my own 'save' button.  It the code behind the button's click event I am attempting to save the edited data back to my content database but the editor1.text property still contains the original unchanged text.  How do I get at the HTML for the edited version.
     
    My client is putting pressure on me to finish this project and I am banging my head aginst the wall trying to solve this, probably simple, issue so all help will be gratefully received.
     
    --
    Regards
    Pete
  •  10-19-2006, 11:41 AM 23703 in reply to 23702

    Re: Cannot access edited data (VB.NET)

    Pete,
     
    Please use Editor.Text property or Editor.XHTML Property to retrieve the CuteEditor HTML content.
     
    Keep me posted
     

     

    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

  •  10-19-2006, 12:47 PM 23710 in reply to 23703

    Re: Cannot access edited data (VB.NET)

    Hi Adam
     
    That is what I am doing.  The .text and .XHTML properties still contain the original version of the code for some reason.  This is my button_Click event - including the response.write staements which I am using for debugging purposes:
     

    Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSave.Click

    Dim contextID As String

    contextID = Request.QueryString("contextID").ToString

    conn.ConnectionString = ConfigurationManager.AppSettings("ConnectionString")

    conn.Open()

    With cmd

    .Parameters.Clear()

    .Connection = conn

    .CommandType = CommandType.StoredProcedure

    .CommandText = "p__SetPublishedContent"

    .Parameters.AddWithValue("@ContextID", contextID)

    .Parameters("@ContextID").DbType = DbType.String

    .Parameters.AddWithValue("@pageText", Editor1.Text)

    Response.Write(Editor1.text)

    Response.End()

    .Parameters("@pageText").SqlDbType = SqlDbType.Text

    .ExecuteNonQuery()

    End With

    Response.Redirect("default.aspx?contextID=" & contextID)

    conn.Close()

    End Sub
     
    As far as I am assuming, the .text property, at this stage, should contain the edited text not the original text as it does.
     
    --
    Regards
    Pete
  •  10-19-2006, 12:58 PM 23711 in reply to 23710

    Re: Cannot access edited data (VB.NET)

  •  10-19-2006, 1:22 PM 23712 in reply to 23702

    Re: Cannot access edited data (VB.NET)

    Hi Adam

    The .aspx file is:

    <%@ Page Language="VB"  Debug="true" MasterPageFile="~/Biolife.master" AutoEventWireup="false" CodeFile="EditPage.aspx.vb" Inherits="Admin_EditPage" title="Untitled Page" %>

    <%@ Register Assembly="CuteEditor" Namespace="CuteEditor" TagPrefix="CE" %>
    <asp:Content ID="Content1" ContentPlaceHolderID="contentPlaceHolder1" Runat="Server">
       
    <CE:Editor ID="Editor1" runat="server" Height="508px">
           
        </CE:Editor>
        <br />
        <center>
            <asp:Button ID="btnSave" runat="server" Text="Save" OnClick="btnSave_Click" />&nbsp;
        </center>
    </asp:Content>

    (The <form> declaration is in the master page immediately above the contentplaceholder)

    The .vb file is:

    Imports System.Data
    Imports System.Data.SqlClient
    Imports System.Configuration
    Imports CuteEditor.EditorSetting

    Partial Class Admin_EditPage
        Inherits System.Web.UI.Page
        Dim conn As New SqlConnection
        Dim cmd As New SqlCommand
        Dim contextID As String
        Dim sectionID As String
        Friend dsContext As New DataSet

        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            If Request.QueryString("ContextID") <> String.Empty Then
                If Len(Trim(Request.QueryString("ContextID").ToString)) = 0 Then
                    contextID = "00"
                Else
                    contextID = Request.QueryString("contextID").ToString
                End If
            End If
            If Request.QueryString("SectionID") <> String.Empty Then
                If Len(Trim(Request.QueryString("SectionID").ToString)) = 0 Then
                    sectionID = ""
                Else
                    sectionID = Request.QueryString("sectionID").ToString
                End If
            End If
            conn.ConnectionString = ConfigurationManager.AppSettings("ConnectionString")
            conn.Open()
            If Session("live") = "true" Then
                If sectionID = "" Then
                    With cmd
                        .Parameters.Clear()
                        .Connection = conn
                        .CommandType = CommandType.StoredProcedure
                        .CommandText = "p__GetPublishedContent"
                        .Parameters.AddWithValue("@ContextID", contextID)
                        .Parameters("@ContextID").DbType = DbType.String
                    End With
                    Dim daContext As New SqlDataAdapter(cmd)
                    daContext.Fill(dsContext)
                    conn.Close()
                Else
                    With cmd
                        .Parameters.Clear()
                        .Connection = conn
                        .CommandType = CommandType.StoredProcedure
                        .CommandText = "p__GetPublishedContent"
                        .Parameters.AddWithValue("@ContextID", contextID)
                        .Parameters("@ContextID").DbType = DbType.String
                        .Parameters.AddWithValue("@SectionID", sectionID)
                        .Parameters("@SectionID").DbType = DbType.String
                    End With
                    Dim daContext As New SqlDataAdapter(cmd)
                    daContext.Fill(dsContext)
                    conn.Close()
                End If
            Else
                With cmd
                    .Parameters.Clear()
                    .Connection = conn
                    .CommandType = CommandType.StoredProcedure
                    .CommandText = "p__GetPendingContent"
                    .Parameters.AddWithValue("@ContextID", contextID)
                    .Parameters("@ContextID").DbType = DbType.String
                End With
                Dim daContext As New SqlDataAdapter(cmd)
                daContext.Fill(dsContext)
                conn.Close()
            End If
            Editor1.Text = dsContext.Tables(0).Rows(0)("Source")

        End Sub



        Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSave.Click
            Dim contextID As String
            contextID = Request.QueryString("contextID").ToString
            conn.ConnectionString = ConfigurationManager.AppSettings("ConnectionString")
            conn.Open()
            With cmd
                .Parameters.Clear()
                .Connection = conn
                .CommandType = CommandType.StoredProcedure
                .CommandText = "p__SetPublishedContent"
                .Parameters.AddWithValue("@ContextID", contextID)
                .Parameters("@ContextID").DbType = DbType.String
                .Parameters.AddWithValue("@pageText", Editor1.Text)
                Response.Write(Editor1.Text)
                Response.End()
                .Parameters("@pageText").SqlDbType = SqlDbType.Text
                .ExecuteNonQuery()
            End With
            Response.Redirect("default.aspx?contextID=" & contextID)
            conn.Close()
        End Sub
    End Class



    Thanks for your help.

    --
    Regards
    Pete

  •  10-19-2006, 1:32 PM 23713 in reply to 23712

    Re: Cannot access edited data (VB.NET)

    Problem is here:
     
     
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            If Request.QueryString("ContextID") <> String.Empty Then
                If Len(Trim(Request.QueryString("ContextID").ToString)) = 0 Then
                    contextID = "00"
                Else
                    contextID = Request.QueryString("contextID").ToString
                End If
            End If
            If Request.QueryString("SectionID") <> String.Empty Then
                If Len(Trim(Request.QueryString("SectionID").ToString)) = 0 Then
                    sectionID = ""
                Else
                    sectionID = Request.QueryString("sectionID").ToString
                End If
            End If
            conn.ConnectionString = ConfigurationManager.AppSettings("ConnectionString")
            conn.Open()
            If Session("live") = "true" Then
                If sectionID = "" Then
                    With cmd
                        .Parameters.Clear()
                        .Connection = conn
                        .CommandType = CommandType.StoredProcedure
                        .CommandText = "p__GetPublishedContent"
                        .Parameters.AddWithValue("@ContextID", contextID)
                        .Parameters("@ContextID").DbType = DbType.String
                    End With
                    Dim daContext As New SqlDataAdapter(cmd)
                    daContext.Fill(dsContext)
                    conn.Close()
                Else
                    With cmd
                        .Parameters.Clear()
                        .Connection = conn
                        .CommandType = CommandType.StoredProcedure
                        .CommandText = "p__GetPublishedContent"
                        .Parameters.AddWithValue("@ContextID", contextID)
                        .Parameters("@ContextID").DbType = DbType.String
                        .Parameters.AddWithValue("@SectionID", sectionID)
                        .Parameters("@SectionID").DbType = DbType.String
                    End With
                    Dim daContext As New SqlDataAdapter(cmd)
                    daContext.Fill(dsContext)
                    conn.Close()
                End If
            Else
                With cmd
                    .Parameters.Clear()
                    .Connection = conn
                    .CommandType = CommandType.StoredProcedure
                    .CommandText = "p__GetPendingContent"
                    .Parameters.AddWithValue("@ContextID", contextID)
                    .Parameters("@ContextID").DbType = DbType.String
                End With
                Dim daContext As New SqlDataAdapter(cmd)
                daContext.Fill(dsContext)
                conn.Close()
            End If
            Editor1.Text = dsContext.Tables(0).Rows(0)("Source")

        End Sub
     
    You reset the content of the Editor on page post back.
     
    Please change it to:
     
     
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

       If Not Page.IsPostBack Then
            If Request.QueryString("ContextID") <> String.Empty Then
                If Len(Trim(Request.QueryString("ContextID").ToString)) = 0 Then
                    contextID = "00"
                Else
                    contextID = Request.QueryString("contextID").ToString
                End If
            End If
            If Request.QueryString("SectionID") <> String.Empty Then
                If Len(Trim(Request.QueryString("SectionID").ToString)) = 0 Then
                    sectionID = ""
                Else
                    sectionID = Request.QueryString("sectionID").ToString
                End If
            End If
            conn.ConnectionString = ConfigurationManager.AppSettings("ConnectionString")
            conn.Open()
            If Session("live") = "true" Then
                If sectionID = "" Then
                    With cmd
                        .Parameters.Clear()
                        .Connection = conn
                        .CommandType = CommandType.StoredProcedure
                        .CommandText = "p__GetPublishedContent"
                        .Parameters.AddWithValue("@ContextID", contextID)
                        .Parameters("@ContextID").DbType = DbType.String
                    End With
                    Dim daContext As New SqlDataAdapter(cmd)
                    daContext.Fill(dsContext)
                    conn.Close()
                Else
                    With cmd
                        .Parameters.Clear()
                        .Connection = conn
                        .CommandType = CommandType.StoredProcedure
                        .CommandText = "p__GetPublishedContent"
                        .Parameters.AddWithValue("@ContextID", contextID)
                        .Parameters("@ContextID").DbType = DbType.String
                        .Parameters.AddWithValue("@SectionID", sectionID)
                        .Parameters("@SectionID").DbType = DbType.String
                    End With
                    Dim daContext As New SqlDataAdapter(cmd)
                    daContext.Fill(dsContext)
                    conn.Close()
                End If
            Else
                With cmd
                    .Parameters.Clear()
                    .Connection = conn
                    .CommandType = CommandType.StoredProcedure
                    .CommandText = "p__GetPendingContent"
                    .Parameters.AddWithValue("@ContextID", contextID)
                    .Parameters("@ContextID").DbType = DbType.String
                End With
                Dim daContext As New SqlDataAdapter(cmd)
                daContext.Fill(dsContext)
                conn.Close()
            End If
            Editor1.Text = dsContext.Tables(0).Rows(0)("Source")
        End If
        End Sub
     
     

    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

  •  10-19-2006, 1:59 PM 23717 in reply to 23713

    Re: Cannot access edited data (VB.NET)

    Thanks Adam

    I had the horrible feeling it might have been me doing something stupid.  The number of times I have written a page_load event, I shouldn't have missed that bit.  Hopefully this thread might save someone else from the same level of frustration.

    Sorry to have bothered you and thank you for your prompt help.

    --
    Regards
    Pete

View as RSS news feed in XML