How can I set a button as default on an aspx page? When the user hits the
Enter button this default button is automtcally clicked.
Thanks,
LouIn ASP.NET 2.0 the panel control has a new DefaultButton property.
Set this property to the ID of a button control and it will be the default
button when focus is in that panel.
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net
"Lou Civitella" <lou@.webersystems.com> wrote in message
news:ucBQh8$PHHA.4492@.TK2MSFTNGP02.phx.gbl...
> How can I set a button as default on an aspx page? When the user hits the
> Enter button this default button is automtcally clicked.
> Thanks,
> Lou
>
Hi,
To your TextBox add a JavaScript event onkeydown using
Attributes.Add().
if pressed key is EnterKey i.e with KeyCode=13 then call the Click()
method of the button(this is the default button)
TextBox1.Attributes.Add("onkeydown", "if(event.keyCode){if
(event.keyCode == 13)
{document.getElementById('"+Button1.UniqueID+"').click();return
false;}} else {return true}; ");
thanks,
aru
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment