Link to home
Start Free TrialLog in
Avatar of kperelman
kperelman

asked on

asp.net login control on master page using vb.net

First, I am new to this so with this in mind, I am using VWD 2008 to create a 3.5 asp.net site with a master page that contains a login control.  I placed the login control in a panel ("panelLogin").  I wanted to customize its look so I created a template.  

Now I want to set the initial focus after the page loads to the username textbox ("username") on the master page.  When the user presses enter on the keyboard, I want to set focus to the password textbox ("password"), and then if they press Enter I want to trigger the login button ("loginbutton").  I see it all the time on other websites but am not sure of the 'commonly accepted' way to accomplish this?  
Avatar of Nic_Hagar
Nic_Hagar
Flag of South Africa image

Hi. I am more of a C# programmer, than VB.NET ... but I have found the following resource for you.

Hope this solves your problem:

http://www.fryan0911.com/2009/02/vbnet-use-enter-key-to-move-focus-to.html


You can also have a look at:

http://www.a1vbcode.com/snippet-2958.asp
ASKER CERTIFIED SOLUTION
Avatar of Espavo
Espavo
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Salim Fayad
Here is something a lot easier:

<html>
	<script type="text/javascript">
		function MoveNext(e)
		{
 
 
var keynum;
var isIE;
 
if(window.event) // IE
  {
  keynum = window.event.keyCode;
	isIE = true;
  }
else if(e.which) // Netscape/Firefox/Opera
  {
  keynum = e.which;
	isIE = false;
  }
 
 
if(keynum == 13)
{
 
	if(isIE)
	{
		event.keyCode = 9;
 
		return false;
	}
	else
	{
		e.which=9;
	}
}
 
		}
	</script>
	<body>
		<input type="text" id="txt1" onkeydown="MoveNext()"/>
		<input type="text" id="txt2" onkeypress="MoveNext()"/>
	</body>
</html>

Open in new window

Avatar of kperelman
kperelman

ASKER

Thanks.  I like the ability of being able to select the control to which to set the focus.