AppSettings not sticking

Last post 04-12-2009, 9:56 PM by Kenneth. 6 replies.
Sort Posts: Previous Next
  •  04-09-2009, 1:40 PM 50936

    AppSettings not sticking

    I have CuteEditor embedded in an edit template.   Upload directory is set in cuteeditor config file, which works fine.  However, I'm changing the upload directory to value in web.config on page load.  This also works fine the first time the page loads. 
     
    The problem is that after I save the form, and the page posts back, the codebehind app settings (below) are not being recognized and the upload directories go back to default config file settings.  This happens despite setting the new upload directory in page load event.
     
    Here is the code in the Page_Load.
     
        Dim editor = CType(frmContentEdit.FindControl("editor1"), Object)
                editor.Setting("security:ImageGalleryPath") = ConfigurationManager.AppSettings("Upload_Path")
                editor.Setting("security:ImageBrowserPath") = ConfigurationManager.AppSettings("Upload_Path")
                editor.Setting("security:MediaGalleryPath") = ConfigurationManager.AppSettings("Upload_Path")
                editor.Setting("security:FlashGalleryPath") = ConfigurationManager.AppSettings("Upload_Path")
                editor.Setting("security:FilesGalleryPath") = ConfigurationManager.AppSettings("Upload_Path")

    Again, this works fine the first time, and the upload screens reference the correct path I change it to above, however, after the post back, it seems the above code is ignored and the editor upload screens then use default upload directories in the cuteeditor config file.
     
    Also, the site is not available for review online.
     
    Do you know what the problem might be?
     
  •  04-09-2009, 3:20 PM 50946 in reply to 50936

    Re: AppSettings not sticking

    Can you create a whole aspx page showing the problem and post the code here?

    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

  •  04-09-2009, 5:42 PM 50953 in reply to 50946

    Re: AppSettings not sticking

    Hi Adam,
    Not really.  Do you need more information, or is my explanation unclear?
  •  04-09-2009, 5:48 PM 50954 in reply to 50946

    Re: AppSettings not sticking

    I have nothing sophisticate going on.  Just basic edit template with editor embedded, with VB/ASP.Net code behind.  I'm simply changing the editor upload path with that code, in page load sub.
     
    The upload path change works when you load the page and upload popups work fine.  However, when the form is submitted (postback) the editor changes back to cuteeditor config upload paths.  
     

  •  04-10-2009, 1:22 AM 50963 in reply to 50954

    Re: AppSettings not sticking

    Hi acer152,
     
    please try this example:
     
    ------------------------------------------->

    <%@ Page Language="VB" %>
    <%@ Import Namespace="System.Data" %>
    <%@ Register Namespace="CuteEditor" Assembly="CuteEditor" TagPrefix="CE" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <script runat="server">
        Private Function CreateDataSource() As ICollection
            Dim dt As New DataTable()
            Dim dr As DataRow
            dt.Columns.Add(New DataColumn("StringValue", GetType([String])))
            For i As Integer = 0 To 1
                dr = dt.NewRow()
                dr(0) = "test" & i
                dt.Rows.Add(dr)
            Next
       
            Dim dv As New DataView(dt)
            Return dv
        End Function
        Private Sub Page_Load(ByVal sender As [Object], ByVal e As EventArgs)
            ItemsList.DataSource = CreateDataSource()
            ItemsList.DataBind()
        End Sub

        Protected Sub ItemsList_ItemDataBound(ByVal sender As Object, ByVal e As DataListItemEventArgs)
            Dim editor1 As Editor = DirectCast(e.Item.FindControl("editor1"), Editor)
            editor1.Setting("security:ImageGalleryPath") = "~/yourFolder"
            editor1.Setting("security:ImageBrowserPath") = "~/yourFolder"
            editor1.Setting("security:MediaGalleryPath") = "~/yourFolder"
            editor1.Setting("security:ImageGalleryPath") = "~/yourFolder"
            editor1.Setting("security:FlashGalleryPath") = "~/yourFolder"
        End Sub

    </script>

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
         <asp:Button ID="button1" runat="server" Text="PostBack" />
                <asp:DataList ID="ItemsList" runat="server" OnItemDataBound="ItemsList_ItemDataBound">
                    <ItemTemplate>
                        <%# DataBinder.Eval(Container.DataItem, "StringValue") %>
                        <CE:Editor ID="editor1" runat="server">
                        </CE:Editor>
                    </ItemTemplate>
                </asp:DataList>
        </form>
    </body>
    </html>
    ------------------------------------------------->
     
    Regards,
     
    Ken
  •  04-10-2009, 6:41 AM 50972 in reply to 50963

    Re: AppSettings not sticking

    Thanks for that.  Not sure if it matters, but the page I have uses master pages.  I did test this on another page, like you have, and changing the editor source was fine.  Do you think master pages would have any impact?
  •  04-12-2009, 9:56 PM 51013 in reply to 50972

    Re: AppSettings not sticking

    Hi acer152,

    MasterPage will not impact this issue, you just need the confirm the code below implementation each time the page load
     
    -------------------------------->
            editor1.Setting("security:ImageGalleryPath") = "~/yourFolder"
            editor1.Setting("security:ImageBrowserPath") = "~/yourFolder"
            editor1.Setting("security:MediaGalleryPath") = "~/yourFolder"
            editor1.Setting("security:ImageGalleryPath") = "~/yourFolder"
            editor1.Setting("security:FlashGalleryPath") = "~/yourFolder"
    --------------------------------->
     
    Regards,
     
    Ken
View as RSS news feed in XML