Re: Cannot access edited data (VB.NET)

  •  10-19-2006, 1:32 PM

    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

View Complete Thread