OnClientCommandExecuting Error

3 posts, 0 answers
  1. Jeff
    Jeff avatar
    8 posts
    Member since:
    May 2012

    Posted 11 Jun 2012 Link to this post

    I added a custom drop down to my editor. I created the OnClientCommandExecuting function to handle what happens when someone selects an item in the drop down.

    The problem is the event fires when I press enter inside the editor, which is causing the following code to throw an error:

    function OnClientCommandExecuting(editor, args) {
     
            var name = args.get_commandName();
            var val = args.get_value();
     
            var info = val.split("::");
     
        }

    Error:

    val is undefined
    (?)(editor=Object { __msdisposeindex=3, _element=div#RadEditor1.RadEditor, _clientStateFieldID="RadEditor1_ClientState", more...}, args=Object { _cancel=false, _commandName="EnterNewLine", _name="EnterNewLine"})TelerikAjax.aspx (line 23)
    createCallback(c=Object { __msdisposeindex=3, _element=div#RadEditor1.RadEditor, _clientStateFieldID="RadEditor1_ClientState", more...}, d=Object { _cancel=false, _commandName="EnterNewLine", _name="EnterNewLine"})Teleri...90a9d4e (line 6)
    raiseEvent(b="commandExecuting", c=Object { _cancel=false, _commandName="EnterNewLine", _name="EnterNewLine"})Core.js (line 766)
    createCallback(a=Object { __msdisposeindex=3, _element=div#RadEditor1.RadEditor, _clientStateFieldID="RadEditor1_ClientState", more...}, d="raiseEvent", b=["commandExecuting", Object { _cancel=false, _commandName="EnterNewLine", _name="EnterNewLine"}])Teleri...90a9d4e (line 6)
    _responseReceived(c="commandExecuting", d=Object { _cancel=false, _commandName="EnterNewLine", _name="EnterNewLine"})RadEditor.js (line 6416)
    _executeCommandEvent(s="commandExecuting", u="EnterNewLine", j=Object { _cancel=false, _commandName="EnterNewLine", _name="EnterNewLine"})RadEditor.js (line 7382)
    fire(m="EnterNewLine", j=undefined)RadEditor.js (line 7363)
    _onKeyDown(t=keydown charCode=0, keyCode=13)RadEditor.js (line 7814)
    (?)(h=keydown charCode=0, keyCode=13)RadEditor.js (line 7739)
    [Break On This Error]  
     
    Reload the page to get source for: http://localhost:56444/TelerikAjax.aspx
     
    TelerikAjax.aspx (line 23)

  2. Jeff
    Jeff avatar
    8 posts
    Member since:
    May 2012

    Posted 11 Jun 2012 Link to this post

    I assume I'm just going to have to check to make sure the value came from the dropdown before I run my routine?
  3. Rumen
    Admin
    Rumen avatar
    14417 posts

    Posted 12 Jun 2012 Link to this post

    Hi,

    You should also check for the executed command before executing your code, e.g.

    function OnClientCommandExecuting(editor, args) {
            var name = args.get_commandName();
            if (name == "CustomDropdownCommandName)
            {
                var val = args.get_value();
                var info = val.split("::");
            }
    }


    Greetings,
    Rumen
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top