Set default button

L

Lou Civitella

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
 
S

Steve C. Orr [MCSD, MVP, CSM, ASP Insider]

In 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.
 
A

Arundhati Anavekar

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top