Support forums
in

Click Save Button Event

Last post 11-13-2006, 6:48 PM by tamaule. 9 replies.
Sort Posts: Previous Next
  •  09-22-2005, 2:46 PM 10917

    Click Save Button Event

    Per Adam's suggestion I've been checking out the Capture_Save_Button_Click code in order to learn how to set up my own save event and have questions.

    I added the vb version of the Capture_Save_Button_Click files to my application.
     
    How come I can't affect changes to the btn.Text string or the Editor1.Text string via editing the Capture_Save_Button_Click.aspx.vb file (the 'codebehind' file)?

    I tried editing the vb codebehind page via VS2005, saving the changes, and browsing to the page but the changes do not appear on the displayed capture_save_button_click.aspx page. I made sure I wasn't viewing a cached web page.

    For example, I tried changing the Editor1.Text string from "Type Here" to "Type What You Want Here" but after saving the changes to the vb file I continue to see "Type Here" displayed when browsing the aspx page. Clicking on the browser's refresh button made no difference.
  •  09-22-2005, 2:57 PM 10918 in reply to 10917

    Re: Click Save Button Event

    Have you recompiled your project after you modified the code-behind page?
     
     

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  09-22-2005, 4:28 PM 10923 in reply to 10918

    Re: Click Save Button Event

    Using VS2005, within the BUILD drop-down menu, I clicked on Build Website. After about 20 seconds the Error List appeared describing 4 errors. Each of the errors mentioned the the _sharedie.htm file. Apparantly this file did not become a part of my local copy of the website (The website is located on a remote webserver - a virtual domain called hybridrepair.com).
     
    For example, error #1 stated:
     
    DESCRIPTION:
    Could not find file 'C:\Documents and Settings\John Happy III\Local Settings\Temp\VWDWebCache\www.hybridrepair.com\CuteSoft_Client\CuteEditor\_sharedie.htm'.
     
    FILE:
    Tag_Table.ascx
     
    LINE:
    101
     
    Error #2 had the same description and:
     
    FILE:
    Tag_InsertTable.ascx
     
    LINE:
    173
     
    Error #3 had the same description and:
     
    FILE:
    Tag_TD.ascx
     
    LINE
    71
     
    Error #4 had the same description and:
     
    FILE:
    Tag_TR.ascx
     
    LINE:
    71
     
    After the build was finished I browsed to the capture_save_button_click.aspx page but did not see the changes I made to the codebehind file.
  •  09-22-2005, 4:41 PM 10924 in reply to 10923

    Re: Click Save Button Event

    I pasted the missing _sharedie.htm file as well as the missing _shared.htm file into my local copy of the website and ran the build again. This time I ended up with 20+ errors and 15 warnings. I then removed the local copies of _sharedie.htm and _shared.htm and my build error messages returned to 4.
  •  09-23-2005, 10:56 AM 10956 in reply to 10924

    Re: Click Save Button Event

    Hi John,
     
    Are you using the version 5.0?
     
    It looks like you are using the 4.0.0.x??
     
     

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  09-23-2005, 2:36 PM 10971 in reply to 10956

    Re: Click Save Button Event

    Yesterday, after posting the above, I removed my version 4.5 copy of the software and installed the 5.0 version.
     
    I opened the Capture Save codebehind file and tried to change the button text and the Label1 text but could not affect the changes. I made sure when I made my changes via VS2005 that both my local copy of the codebehind file and the copy on my remote webserver was changed. 
    The codebehind file on my webserver has the following code in it:
     

    Private 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()

            Editor2.Attributes("oncommand") = "HandleEditorCommand(this)"

        End Sub

        Private 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

    The changes I made to the original code are in red.

    You can view the file by going to:

    http://www.hybridrepair.com/HowTo/CatchSave/capture_save_button_click.aspx
     
     
  •  09-23-2005, 3:49 PM 10974 in reply to 10971

    Re: Click Save Button Event

    Made some changes ... getting closer ... changes to Label1.Text are still a problem ...
     
    Based on some input form a Google search and my VS2005 Error List, I made the following changes to the capture_save_button_click.aspx file:
     
    OLD CODE:
    <%@ Page Language="vb" AutoEventWireup="false" Codebehind="capture_save_button_click.aspx.vb" Inherits="CuteEditorWeb_vb.capture_save_button_click"%> 
     
    NEW CODE:
    <%@ Page Language="vb" AutoEventWireup="false" Codefile="capture_save_button_click.aspx.vb" Inherits="capture_save_button_click"
    %>
     
    Codebehind was changed to Codefile and I removed CuteEditorWeb_vb from the Inherits string.
     
    I also changed the codebehind file as follows:
     
    OLD CODE:
    Protected WithEvents Editor1 As CuteEditor.Editor
    Protected WithEvents Editor2 As CuteEditor.Editor
    Protected WithEvents Label1 As System.Web.UI.WebControls.Label

    NEW CODE:
    'Protected WithEvents Editor1 As CuteEditor.Editor
    'Protected WithEvents Editor2 As CuteEditor.Editor
    'Protected WithEvents Label1 As System.Web.UI.WebControls.Label

    I was prompted to comment out the Protected WithEvents code because, for example, if I 'uncommented' the Protected WithEvents Editor1 line, I received this error:

    ERROR #
    Error 2
    DESCRIPTION
    'Editor1' is already declared as 'Protected Dim WithEvents Editor1 As CuteEditor.Editor' in this class. 
    FILE:
    C:\Documents and
    Settings\John Happy III\Local Settings\Temp\VWDWebCache\www.hybridrepair.com\howto\CatchSave\capture_save_button_click.aspx.vb
    LINE:
    22
    COLUMN
    26
    PROJECT:
    http://www.hybridrepair.com/

    My remaining problem is that Label1.Text now does not change when the SAVE or BUBBLE BUTTON is clicked.


     




     
  •  09-23-2005, 4:55 PM 10975 in reply to 10974

    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 .
  •  09-23-2005, 6:36 PM 10976 in reply to 10975

    Re: Click Save Button Event

  •  11-13-2006, 6:48 PM 24295 in reply to 10975

    Re: Click Save Button Event

    Thank you for this post - I have been battling this the entire day. It works perfectly!
View as RSS news feed in XML
Powered by Community Server (Commercial Edition), by Telligent Systems