Capture New and Delete Events

Last post 05-15-2009, 2:10 PM by robinsong. 5 replies.
Sort Posts: Previous Next
  •  05-12-2009, 6:39 PM 52091

    Capture New and Delete Events

    How can I capture the New Document and Delete event?  I found your example for the "Save" button.
     
     
    Thanks.
  •  05-14-2009, 3:35 AM 52147 in reply to 52091

    Re: Capture New and Delete Events

    Hi robinsong,
     
    Try this way:
     
    ------------------------------------------------------------------------->
     

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

    <%@ 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">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form>
            <CE:Editor ID="Editor1" runat="server">
            </CE:Editor>
        </form>
    </body>
    </html>

    <script language="JavaScript" type="text/javascript">
      var editor1=document.getElementById("<%=Editor1.ClientID%>");
      
      function CuteEditor_OnCommand(editor,command,ui,value)
      {
       
       if(command=="New")
       {
        alert("New");
        return true;
       }
       if(command=="Delete")
       {
        alert("Delete");
        return true;
       }
      }
    </script>

     ------------------------------------------------------------------------->
     
    Regards,
     
    Ken
  •  05-14-2009, 1:43 PM 52166 in reply to 52147

    Re: Capture New and Delete Events

    I am tryint to capture the event in the code behind.  The save works
     

    Public Sub Editor1_PostBackCommand(ByVal Sender As Object, ByVal e As System.Web.UI.WebControls.CommandEventArgs)

    If String.Compare(e.CommandName, "Save", True) = 0 Then

    'Label1.Text = "<h3>You just clicked the <font color=red>Save</font> button</h3>"

    Update()

    ElseIf String.Compare(e.CommandName, "New", True) = 0 Then

    Insert()

    ElseIf String.Compare(e.CommandName, "Delete", True) = 0 Then

    delete()

    Else

    Label1.Text = "<h3>Just recived the bubbled command : " + e.CommandName + " </h3>"

    End If

    End Sub

  •  05-14-2009, 1:43 PM 52167 in reply to 52166

    Re: Capture New and Delete Events

    To be more clear on the above.  The save gets captured but the new and delete do not.
  •  05-15-2009, 4:47 AM 52180 in reply to 52167

    Re: Capture New and Delete Events

    Hi robinsong,
     
    Try this example:
     
    ------------------------------------------------------------------------->
     

    <%@ Page Language="VB" %>

    <%@ 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">
        Public Sub newCilck()
            label1.Text = "New"
        End Sub
        Public Sub deleteClick()
            label1.Text = "Delete"
        End Sub

        Protected Sub btnNew_Click(ByVal sender As Object, ByVal e As EventArgs)
            newCilck()
        End Sub

        Protected Sub btnDelete_Click(ByVal sender As Object, ByVal e As EventArgs)
            deleteClick()
        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">
            <CE:Editor ID="Editor1" runat="server">
            </CE:Editor>
            <asp:Button ID="btnNew" runat="server" OnClick="btnNew_Click" Style="visibility: hidden" />
            <asp:Button ID="btnDelete" runat="server" Style="visibility: hidden" OnClick="btnDelete_Click" />
            <asp:Label ID="label1" runat="server"></asp:Label>

            <script language="JavaScript" type="text/javascript">
      function CuteEditor_OnCommand(editor,command,ui,value)
      {
      
       if(command=="New")
       {
         var btnNew=document.getElementById("<%= btnNew.ClientID %>").click();
         return true;
       }
       if(command=="Delete")
       {
         var btnDelete=document.getElementById("<%= btnDelete.ClientID %>").click();
        return true;
       }
      }
            </script>

        </form>
    </body>
    </html>

     ------------------------------------------------------------------------->
     
    Regards,
     
    Ken
  •  05-15-2009, 2:10 PM 52199 in reply to 52180

    Re: Capture New and Delete Events

    That works.  Thanks
View as RSS news feed in XML