By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,463 Members | 3,115 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,463 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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.