473,395 Members | 1,516 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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 9818
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: tshad | last post by:
I posted this on the asp.net group, also. I wasn't sure whether this was an asp.net problem or a javascript problem. I have a page that was originally created from a program I found on the net...
8
by: Zelin Lu | last post by:
Hello, All I am building two user controls and dynamicly load one them into a PlaceHolder. But the button on the user control doesn't work fine. I need to click twice to fire the event? ...
5
by: Carlo Marchesoni | last post by:
From an aspx page (A.aspx) I open another one (B.aspx - for table lookup). When the user selects an entry in B.aspx I would like to force a button's event in A.aspx to be fired. I guess the only...
1
by: Dan | last post by:
I have an asp.net page default.aspx with a user control and a placeholder control. <html> <body> <form id="myform" method="post" runat="server" /> <PageHeader:Header id="header1"...
6
by: martin | last post by:
Hi, I am a web page and a web user control. My web user control is placed in my web page using the following directive <%@ Register TagPrefix="uc1" TagName="Header"...
0
by: Oz | last post by:
Hi Using VS.NET 2003, Windows XP SP1, We have a page which has been developed using ASP.NET. On it, is a button which when clicked is supposed to add some data to a table. When the button is...
5
by: Rocky Moore | last post by:
Been a while since I looked into this and have forgotten how to make the ENTER default to a LinkButton and it does on a standard button. If I remember correctly it required javascript. Thanks ...
5
by: Neo Geshel | last post by:
Greetings. I am in a very big pickle. I am trying to add page content - as well as a submit button - programatically to a web form that is supposed to submit to DB and then refresh. That...
9
by: Neo Geshel | last post by:
I have strip-mined, strip-searched, and completely exhausted the Internet (up to the 30th page on Google, with 100 results per page!!), all without finding an answer to my question AS TO WHY IT...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.