views:

35

answers:

1

When I press enter in my loginform, my search form at the top of the website runs instead. I'm trying to handle the enter key but I keep getting a missingmemberexception.

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)

        Dim getButton As New findbuttonControl
        Dim vButton As Object
        Dim getPassword As New findChildControl
        Dim vPassword As Object

        vButton = getButton.getGrandChildValue(Me.LoginView1.Controls, "Login1", "LoginButton")
        vPassword = getPassword.getGrandChildValue(Me.LoginView1.Controls, "Login1", "Password")

        vPassword.Attributes.Add("onkeydown", "if(event.which || event.keyCode){if ((event.which == 13) || (event.keyCode == 13)) {document.getElementById('" + vButton + "').click();return false;}} else {return true}; ")
End Sub
+1  A: 

Have a look at the new ASP.Net 2.0 DefaultButton Property.

Tim Schmelter
That's not really an option. Not using multiple form tags.
BioXhazard