user3867603 user3867603 - 1 month ago 14
ASP.NET (C#) Question

Need to add keydown event for ASP.net Text box and need to trigger a codebehind function using the keydown event

The page load event:

txtName.Attributes.Add("onkeyup", "return doDataListBind()");`


Javascript:

function doDataListBind()
{
document.getElementById("Button2").click();
}


Created a button and tried to trigger on-click event using JavaScript.

Answer

In jQuery:

$( "#Button2" ).trigger( "click" );