Re: How to get started with Cute Editor

  •  11-04-2008, 10:50 PM

    Re: How to get started with Cute Editor

    Hi Ken,
    The code is pretty much exaclty as you posted except I changed "editor1" to "editor2" for the 2nd page as follows:

    <%@ Page Language="VB" %>

    <%@ Register TagPrefix="CE" Namespace="CuteEditor" Assembly="CuteEditor" %>
    <!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 GetSavedValue() As String
            Dim obj As Object = Application("myvalue")
            If obj IsNot Nothing Then
                Return obj.ToString()
            End If
            Return "Click here to edit the page"
        End Function
        Private Sub SaveValue(ByVal val As String)
            Application("myvalue") = val
        End Sub

        Protected Overloads Overrides Sub OnLoad(ByVal e As EventArgs)
            MyBase.OnLoad(e)
       
            If Not IsPostBack Then
                Dim val As String = GetSavedValue()
                MyContent.Text = GetSavedValue()
           
               
               
                Editor1.Text = val
            End If
        End Sub

        Protected Sub Editor1_PostBackCommand(ByVal sender As Object, ByVal e As CommandEventArgs)
            If e.CommandName = "Save" Then
           
                SaveValue(Editor1.Text)
               
                MyContent.Text = Editor1.Text
            End If
        End Sub


    </script>

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>Cute Page 1</title>
    </head>
    <body>
        <form id="form1" runat="server">
            <div id="divedit" style="display: none; position: absolute; left: 0px; top: 0px;
                width: 100%; height: 100%; text-align: center; background-color: White; padding-top: 100px;">
                <div>
                    Click save button to save the news...</div>
                <CE:Editor ID="Editor1" runat="server" OnPostBackCommand="Editor1_PostBackCommand">
                </CE:Editor>
            </div>
            <div style="border: solid 1px gray; padding: 12px; margin: 12px;" onclick="showEditor()">
                <asp:Literal ID="MyContent" runat="server"></asp:Literal>
            </div>
        </form>

        <script>
        var haspermossion=true;
        function showEditor()
        {
            if(haspermossion)
            {
                document.getElementById("divedit").style.display="";
            }
        }
        </script>
    </body>
    </html>

    The second page...

    <%@ Page Language="VB" %>

    <%@ Register TagPrefix="CE" Namespace="CuteEditor" Assembly="CuteEditor" %>
    <!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 GetSavedValue() As String
            Dim obj As Object = Application("myvalue")
            If obj IsNot Nothing Then
                Return obj.ToString()
            End If
            Return "Click here to edit the page"
        End Function
        Private Sub SaveValue(ByVal val As String)
            Application("myvalue") = val
        End Sub

        Protected Overloads Overrides Sub OnLoad(ByVal e As EventArgs)
            MyBase.OnLoad(e)
       
            If Not IsPostBack Then
                Dim val As String = GetSavedValue()
                MyContent.Text = GetSavedValue()
           
               
               
                editor2.Text = val
            End If
        End Sub

        Protected Sub editor2_PostBackCommand(ByVal sender As Object, ByVal e As CommandEventArgs)
            If e.CommandName = "Save" Then
           
                SaveValue(editor2.Text)
               
                MyContent.Text = editor2.Text
            End If
        End Sub


    </script>

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>CutePage 2</title>
    </head>
    <body>
        <form id="form1" runat="server">
            <div id="divedit" style="display: none; position: absolute; left: 0px; top: 0px;
                width: 100%; height: 100%; text-align: center; background-color: White; padding-top: 100px;">
                <div>
                    Click save button to save the news...</div>
                <CE:Editor ID="editor2" runat="server" OnPostBackCommand="editor2_PostBackCommand">
                </CE:Editor>
            </div>
            <div style="border: solid 1px gray; padding: 12px; margin: 12px;" onclick="showEditor()">
                <asp:Literal ID="MyContent" runat="server"></asp:Literal>
            </div>
        </form>

        <script>
        var haspermossion=true;
        function showEditor()
        {
            if(haspermossion)
            {
                document.getElementById("divedit").style.display="";
            }
        }
        </script>
    </body>
    </html>

    When I change one page, the other page changes accordingly.
    Thanks for checking this out.
    Bob
View Complete Thread