Last post Dec 03, 2008 10:04 AM by pedlin
Nov 27, 2008 09:33 AM|pedlin|LINK
I have a Usercontrol with a form property "Defaultbutton=btnGo" which is the second button in my form. I can'nt get this to work - my first button in the form is the one that acts as the default button on the page.
- since this is a usercontrol, the button is beeing named with the prefix ctl00_BodyContentPlaceHolder_test_btnPay (when i look at the source code). I tried to set the defaultbutton=ctl00_BodyContentPlaceHolder_test_btnPay, but it still did'n work (probably to easy of a workaround :-)
Any suggestions on how to solve this?
Nov 27, 2008 10:45 AM|Erwin21|LINK
Use: DefaultButton= btnGo.ClientID;
Dec 02, 2008 03:48 AM|pedlin|LINK
Thanks for the answer, but I still don't get it to work. When I load the page, the button now has the focus, but if I go to one of my text boxes on the page and then hit the Enter key, the btnGo is not clicked.
The source code has now added the script:
This is the same kind of script I get if I set the DefaultFocus property of the form. I assume there should be another script when I set the DefaultButton property?
Dec 02, 2008 09:24 AM|bgs264|LINK
Why not try an <asp:Panel DefaultButton="btnGo"> [user control content] </asp:Panel>
(Presuming the btnGo is within the user control...] - I've never had much luck with setting default buttons on the form tag.
Dec 02, 2008 02:35 PM|Erwin21|LINK
Dec 03, 2008 02:31 AM|pedlin|LINK
But the DefaultFocus is what I already got. I want the button to be the default button when the enter key is hit.
Now it seems like the button I specify in the DefaultButton gets the focus when I load the page, but it is not the default button.
I will try with a panel, like suggested above.
Dec 03, 2008 10:04 AM|pedlin|LINK
It worked with a panel outside the form in my userControl:
myPanel.DefaultButton = btnGo.ID
Thanx for the help, I'm so happy!