Mark Mark - 2 years ago 99
Javascript Question

Make Keydown(enter) trigger Ajax.ActionLink when selected whith tab index

Could anyone help me out here?
I'm looking to trigger this(below) by just hitting the enter key:

<div id="create_new" tabindex="2">
@Ajax.ActionLink("Create New",
"create_new", new AjaxOptions {
InsertionMode= InsertionMode.Replace,
HttpMethod = "GET"

Answer Source

This works for me:

<div id="create_new">
@Ajax.ActionLink("Create New",
"create_new", "controller_name", null, new AjaxOptions
    UpdateTargetId = "accordion",
    InsertionMode = InsertionMode.Replace,
    HttpMethod = "GET"
}, new { tabindex = 2}

Just have the tabindex in the link instead of the div.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download