Re: Cannot access edited data (VB.NET)

  •  10-19-2006, 1:22 PM

    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

View Complete Thread