This function is in JavaScript.
This function will help to submit form when user press enter key at dropdownlist box.
//if enter key pressed at DropDownList
function onEnterpress(e)
{
//define any varible
var KeyPress
//if which property of event object is supported
if(e && e.which)
{
e = e
//character code is contained in NN4's which property
KeyPress = e.which
}
else
{
e = event
KeyPress = e.keyCode
}
//13 is the key code of enter key
if(KeyPress == 13)
{
//frmLogin is the name of form
document.frmLogin.submit()
return false
}
else
{
return true
}
}
After this just add the event in your code file at pageLoad like is:
Your code file may be in VB.NET or C# so you may add even like this.
ddlDropDownList.Attributes.Add("onKeyPress", "javascript:onEnterpress(event);")
Event is the name of event pressed by user at keyBoard Key.
ddlDropDownList is the name of dropdown on which we want to add event.