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

A

AlecL

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
 
C

Cowboy \(Gregory A. Beamer\)

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.
 
G

Guest

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
 

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

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top