469,619 Members | 2,437 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,619 developers. It's quick & easy.

How to set a button from a user control the default button on an aspx page

Hi All,

I have added a user control onto an aspx page and want to make the
submit button of that user control the default button when the panel
in which the user control is located is visible. I have used the
code:
Page.RegisterHiddenField("__EVENTTARGET", "Login.btnSubmit")
in the Page Load event but this does not make the submit button
default(enter) button. Any ideas on how can I do this. I have also
tried using just the name of the button instead of Login.btnSubmit
which is the nameofcontrol.nameofbutton convention but to no avail.

HELP! Please.

Al

Feb 12 '07 #1
2 9500
If you wish to go this route, set default in the user control or expose the
user control up the stack so you can set the value. To expose up the stack,
set the button to protected instead of private, so you can see it at page
level. This is the proper OO method of setting up user controls (which most
examples DO NOT do).

NOTE: To pass back values properly, unless all work is done in the control,
you will have to raise an event (delegate) and handle on the page level. The
best way to do this is make the user control a complete object with
properties for the different controls.

NOTE (also): If you are using this particular piece on more than one form,
compiling into a server control is often the best option.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com

********************************************
Think outside the box!
********************************************
"AlecL" <sa********@hotmail.comwrote in message
news:11********************@a34g2000cwb.googlegrou ps.com...
Hi All,

I have added a user control onto an aspx page and want to make the
submit button of that user control the default button when the panel
in which the user control is located is visible. I have used the
code:
Page.RegisterHiddenField("__EVENTTARGET", "Login.btnSubmit")
in the Page Load event but this does not make the submit button
default(enter) button. Any ideas on how can I do this. I have also
tried using just the name of the button instead of Login.btnSubmit
which is the nameofcontrol.nameofbutton convention but to no avail.

HELP! Please.

Al
Feb 12 '07 #2
On Feb 12, 7:53 pm, "AlecL" <salmaan...@hotmail.comwrote:
Hi All,

I have added a user control onto an aspx page and want to make the
submit button of that user control the default button when the panel
in which the user control is located is visible. I have used the
code:
Page.RegisterHiddenField("__EVENTTARGET", "Login.btnSubmit")
in the Page Load event but this does not make the submit button
default(enter) button. Any ideas on how can I do this. I have also
tried using just the name of the button instead of Login.btnSubmit
which is the nameofcontrol.nameofbutton convention but to no avail.

HELP! Please.

Al
I think

Page.RegisterHiddenField("__EVENTTARGET", btnSubmit.UniqueID)

should work

Feb 12 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Zelin Lu | last post: by
5 posts views Thread by Carlo Marchesoni | last post: by
6 posts views Thread by martin | last post: by
5 posts views Thread by Rocky Moore | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.