SIGN UP MEMBER LOGIN:    
ARTICLE

How to Submit Form When User Press Enter Key on DropDownList Box

Posted by Amit M Articles | How do I May 25, 2007
Tags: enter key
This small codes written in JavaScript will help you to submit form when user press enter key on dropdownlist.
Reader Level:

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.

Login to add your contents and source code to this article
share this article :
post comment
 
Team Foundation Server Hosting
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Team Foundation Server Hosting
Become a Sponsor