How to get started with Cute Editor(zz)

Hi jfeeney,
 
you can try following code
 

<%@ Page Language="C#" %>

<%@ 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">
   
    public bool HasEditPermissions
    {
        get
        {
            return true;
        }
    }
   
    private string GetSavedValue()
    {
        object obj = Application["myvalue"];
        if (obj != null)
            return obj.ToString();
        return "Click here to edit the news !";
    }
    void SaveValue(string val)
    {
        Application["myvalue"] = val;
    }

    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);

        if (!IsPostBack)
        {
            string val=GetSavedValue();
            MyContent.Text = GetSavedValue();
            if (HasEditPermissions)
            {
                Editor1.Text = val;
            }
            else
            {
                Editor1.Visible = false;
            }
        }
    }

    protected void Editor1_PostBackCommand(object sender, CommandEventArgs e)
    {
        if (e.CommandName == "Save")
        {
            if (HasEditPermissions)
            {
                SaveValue(Editor1.Text);
                MyContent.Text = Editor1.Text;
            }
        }
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</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=<%=HasEditPermissions?"true":"false" %>;
   
    function showEditor()
    {
        if(haspermossion)
        {
            document.getElementById("divedit").style.display="";
        }
    }
    </script>

</body>
</html>

posted @ 2008-10-19 20:42  stu_acer  阅读(208)  评论(0编辑  收藏  举报