May 28, 2013, 2:51 PM
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.