Add KeyMap in code behind and call Direct Method

  1. #1

    Add KeyMap in code behind and call Direct Method

    Hi. I want to add "KeyMap" to My Base UserControl that when I press for example "Ctrl+Alt+S" a Method in server Side to be invoke. I wrote this code, but nothings happen when I Press this buttons. what is a problem with this code.

        public class BaseUserControl : UserControl
        {
            protected override void OnLoad(EventArgs e)
            {
                try
                {
                    base.OnLoad(e);
                    if (!X.IsAjaxRequest)
                    {
                        var km = new KeyMap
                        {
                            ID = ID + "_KeyMap",
                            Target = ID
                        };
                        var kb = new KeyBinding
                        {
                            Ctrl = true,
                            Alt = true,
                            Handler = "Ext.net.DirectMethods.SaveSecurityTagClicked();"//"alert('hiiiiiiiiiiiii')" //"App.direct.SaveSecurityTagClicked()"
                        };
                        kb.Keys.Add(new Key
                        {
                            Code = KeyCode.S
                        });
                        km.AddKeyBinding(kb);
                        Controls.Add(km);
                    }
                }
                catch (Exception exception)
                {
                    //do what is needed
                }
            }
            [DirectMethod]
            public void SaveSecurityTagClicked()
            {
                throw new Exception("salam");
            }
        }
    thank you for attention.
    Last edited by ali; May 28, 2013 at 3:02 PM.

Similar Threads

  1. [CLOSED] Direct Event/Method Call Priority
    By bayoglu in forum 2.x Premium Help
    Replies: 5
    Last Post: Feb 08, 2013, 2:04 PM
  2. [CLOSED] how to call direct method
    By tactime10 in forum 2.x Premium Help
    Replies: 2
    Last Post: Oct 04, 2012, 8:38 AM
  3. [CLOSED] Can I use Response object in a direct method call?
    By feanor91 in forum 2.x Premium Help
    Replies: 2
    Last Post: Jun 12, 2012, 11:50 AM
  4. how to call direct method in asp.net mvc3
    By waqasde in forum 2.x Help
    Replies: 1
    Last Post: Mar 16, 2012, 9:26 AM
  5. Replies: 5
    Last Post: Jun 22, 2010, 5:17 AM

Tags for this Thread

Posting Permissions