Default button inside a custom control

K

KJ

I have seen examples on how to set the default button on a ASPX page
with asp server controls

Sub Page_Load()

Page.RegisterHiddenField("__EVENTTARGET", "btnSearch")

End Sub

But that does not work if your default button is inside a custom
control on a ASP.NET page. If someone think is does let me know what
I'm doing wrong.

Are they any way I can make that work?

Thanks in advance
 
S

Steve C. Orr, MCSD

Try modifying your code like this to make sure you're getting the full
correct client side control id at run time:
Page.RegisterHiddenField("__EVENTTARGET", btnSearch.ClientID)
 
S

S. Justin Gengo

KJ,

I've use this script to set my default buttons from a text box. With a
little modification it would work from other objects if you aren't using it
from a text box.

TextBox.Attributes.Add("onkeydown", "javascript:if((event.which &&
event.which == 13) || (event.keyCode && event.keyCode ==
13)){document.Form1." & Button.ClientID & ".click();return false;}else
return true;")

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
 

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

Top