Default button inside a custom control

  • Thread starter Thread starter KJ
  • Start date Start date
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
 
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)
 
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
 
Back
Top