Re: Reviewing the CuteEditor Database example

  •  10-11-2008, 8:15 AM

    Re: Reviewing the CuteEditor Database example

    Hi jfeeney,
     
     
    please try this example:

    <%@ 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">
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            if (!IsPostBack)
            {
                ArrayList values = new ArrayList();

                values.Add("Apple");
                values.Add("Orange");
                values.Add("Pear");
                values.Add("Banana");
                values.Add("Grape");

                // Set the DataSource of the Repeater.
                Repeater1.DataSource = values;
                Repeater1.DataBind();

            }

        }
        protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if (e.CommandName == "edit")
            {
                CuteEditor.Editor editor = (CuteEditor.Editor)e.Item.FindControl("editor1");
                Button Save = (Button)e.Item.FindControl("Save");
                Save.Visible = true;
                editor.Visible = true;
            }
            if (e.CommandName == "Save")
            {
                CuteEditor.Editor editor = (CuteEditor.Editor)e.Item.FindControl("editor1");
                Button Save = (Button)e.Item.FindControl("Save");
                Label label1 = (Label)e.Item.FindControl("label1");
                label1.Text = editor.Text;
                editor.Visible = false;
                Save.Visible = false;
            
            }
        }
    </script>

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
            <div>
                <asp:Repeater ID="Repeater1" runat="server" OnItemCommand="Repeater1_ItemCommand">
                    <ItemTemplate>
                        <asp:Label ID="label1" runat="server" Text='<%# Container.DataItem %>'></asp:Label>
                        <asp:Button ID="button1" runat="server" Text="Edit" CommandName="edit" />
                             <asp:Button ID=Save runat=server  Visible=false CommandName=Save Text=Save/>
                        <CE:Editor ID="editor1" runat="server" Visible="false">
                        </CE:Editor>
                  
                    </ItemTemplate>
                </asp:Repeater>
            </div>
        </form>
    </body>
    </html>
     
     
     
    Regards,
     
     
    Ken
View Complete Thread