Using ExecCommand with custom commands

Last post 02-23-2007, 2:30 PM by Adam. 2 replies.
Sort Posts: Previous Next
  •  02-23-2007, 4:35 AM 26929

    Using ExecCommand with custom commands

    Is it possible to use the javascript ExecCommand to cause a postback with a command other than one of the predefined commands?
     
    I have created a new command button SaveAndExit that causes a postback. I did this by simply adding it to the .config file. This works as expected, but I now want to call this custom command using ExecCommand from javascript but keep getting an error saying the command is not defined or supported. Is this actually possible, if not can you suggest an alternative?
     
    As background I am trying to force a save when a browser window closes, but I must distinguish between Save and SaveAndExit so cannot use ExecCommand("Save").
     
    Regards
    Colin
  •  02-23-2007, 4:58 AM 26930 in reply to 26929

    Re: Using ExecCommand with custom commands

    I found ExecCommand("PostBack") in the forums (not in the docs as far as I could see). This allows me to assume that if the command is "undefined" it is a javascript initiated "SaveAndExit".
     
    HOWEVER, it would be neat if there was a more elegant solution, ie. allowing our own defined commands to be called using ExecCommand, or to set command name as follows:-
     
    ExecCommand("SaveAndExit");
    ExecCommand("Postback", "SaveAndExit");
     
    Can this be done?
     
    Regards
    Colin
  •  02-23-2007, 2:30 PM 26940 in reply to 26930

    Re: Using ExecCommand with custom commands

    Colin,
     
    ExecCommand doesn't support any custom button. All the support commands can be found in http://cutesoft.net/developer+guide/index.html.
     
    For your questions, I suggest you create a custom button. When the user click this button, you can call you own javaScript then post back the form.
     
    For example:
     
    <script>
       function MyCustomButton ()
      {
              //run your own script here.
              alert("Hello");

                // get the cute editor instance        
             var editor1 = document.getElementById('<%=Editor1.ClientID%>');
             editor1.ExecCommand("PostBack");
       
      }
     
    </script>
     

    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

View as RSS news feed in XML