Re: Click Save Button Event

  •  09-23-2005, 4:55 PM

    Re: Click Save Button Event

    Yahoo .... it appears I have edited the code correctly to get it working using VB2005 (Beta 2).
     
    I am no longer using the codebehind file. The code is consolidated into one aspx file. The working code is as follows:
     

    <%@ Page Language="VB" %>

    <%@ Register TagPrefix="CE" Namespace="CuteEditor" Assembly="CuteEditor" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

    <script runat="server">
     
    Public Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    If Not Page.IsPostBack Then
     
        Editor1.Text = "Type Something Here"

    End If

    Dim btn As New System.Web.UI.WebControls.Button

    btn.Text = "Hello Joe"

    'this command would fire to the parent of the btn until be processed
    'CuteEditor catch the CommandEventArgs of child controls,and fired it as PostBackCommand
    btn.CommandName = "Hello"
    btn.Style("vertical-align") = "middle"
    Editor1.AddToolbarLineBreak()
    Editor1.AddToolbarGroupStart()
    Editor1.AddToolControl(btn)
    Editor1.AddToolbarGroupEnd()

    End Sub

    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 Save</font> button</h3>"

    Else

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

    End If

    End Sub

    </script>

    <html xmlns="http://www.w3.org/1999/xhtml" >

    <head>

    <title>ASP and ASP.NET WYSIWYG Editor - How to capture the save button click event? </title>
    <link rel="stylesheet" href="../../example.css" type="text/css" />
    </head>
    <body >
    <form runat="server" ID="Form1">
    <h2>How to capture the save button click event?</h2> <hr>
    <h4><asp:Label id="Label1" runat="server">Capture at server side</asp:Label>&nbsp;</h4>
    <p>
    <CE:Editor ID="Editor1" runat="server" OnPostBackCommand="Editor1_PostBackCommand"></CE:Editor>
    &nbsp;</p>
    </form>
    </body>
    </html>
     
    The change that got the Label1 text to change when a user clicks on either the Save or bubble button was within the CE tag. Note the addition of the OnPostBackCommand="Editor1_PostBackCommand" string.
     
    The working file can now be viewed at http://www.hybridrepair.com/howto/catchsave/catchsave.aspx .
View Complete Thread