473,386 Members | 1,606 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,386 software developers and data experts.

Default Button

JJ
What trouble I'm having setting default buttons on a page (with a master
page).

I got around doing it on a page basis by calling the
SetWizardDefaultButton() routine [see below] from page load. Notice how
messy it looks because I could not find the required button any other way
but by using the id it is given in the source code. I tried every
combination of nested 'findcontrol' methods I could think of, but none
worked??!! It seems to be impossible if the button generated on the fly, as
it seems to be in a wizard control. Is there a simpler and tidier way of
doing this?

My main issue here is how to do in from a custom control? If I am writing a
login control that will be in the corner of my master page, I want to "set
login button as default button if no other control on the page wants to do
the same". The problem is that the login button is again, generated on the
fly as its in a loginview control. This time using the source codes
generated id doesn't seem to work at all. What am I doing wrong??
Routine (that works even if it is untidy) that sets the default button. This
is called in the page load of a page derviced from the master page. But how
would I do the same for a control that is placed on either a page or the
master page itself?:
protected void SetWizardDefaultButton()

{

Control theButton;

int StepIndex = CreateUserWizard1.ActiveStepIndex;

if (StepIndex == 0)

{

theButton =
this.FindControl("ctl00$MainContent$CreateUserWiza rd1$__CustomNav0$btn_CreateUserButton");

}

else

{

theButton =
this.FindControl("ctl00$MainContent$CreateUserWiza rd1$CompleteStepContainer$ContinueButton");

}

Master.Page.Form.DefaultButton = theButton.UniqueID;

}
Oct 13 '06 #1
1 2134
JJ
also, how would you set a default button dynamically? i.e. if there are two
controls on a page with input fields and submit buttons, and a user clicks
in one of the input fields, how could you ensure that the deafult button was
that of the control they were currently using.

This functionality is really basic stuff, yet I can't find a solution that
works for wizards etc anywhere. There must be someone out there that knows a
solutions to this?

JJ
"JJ" <ab*@xyz.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
What trouble I'm having setting default buttons on a page (with a master
page).

I got around doing it on a page basis by calling the
SetWizardDefaultButton() routine [see below] from page load. Notice how
messy it looks because I could not find the required button any other way
but by using the id it is given in the source code. I tried every
combination of nested 'findcontrol' methods I could think of, but none
worked??!! It seems to be impossible if the button generated on the fly,
as it seems to be in a wizard control. Is there a simpler and tidier way
of doing this?

My main issue here is how to do in from a custom control? If I am writing
a login control that will be in the corner of my master page, I want to
"set login button as default button if no other control on the page wants
to do the same". The problem is that the login button is again, generated
on the fly as its in a loginview control. This time using the source codes
generated id doesn't seem to work at all. What am I doing wrong??
Routine (that works even if it is untidy) that sets the default button.
This is called in the page load of a page derviced from the master page.
But how would I do the same for a control that is placed on either a page
or the master page itself?:
protected void SetWizardDefaultButton()

{

Control theButton;

int StepIndex = CreateUserWizard1.ActiveStepIndex;

if (StepIndex == 0)

{

theButton =
this.FindControl("ctl00$MainContent$CreateUserWiza rd1$__CustomNav0$btn_CreateUserButton");

}

else

{

theButton =
this.FindControl("ctl00$MainContent$CreateUserWiza rd1$CompleteStepContainer$ContinueButton");

}

Master.Page.Form.DefaultButton = theButton.UniqueID;

}


Oct 13 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Billy Jacobs | last post by:
Is there a way to make a button on a web form the default button so that when the user hits the enter button the code for that button executes? I have a web page Login.aspx where I have only 1...
0
by: Shixx | last post by:
Hello, I have problem in my web application and my web form. I have 5-6 buttons (web controls) and when I have focus on some text box, always one button becomes default and got focus, and after I...
3
by: Marty McFly | last post by:
Hello, I have a control class that inherits from System.Web.UI.WebControls.Button. When I drag this control from the "My User Controls" tab in the toolbox onto the form, I want it to reflect the...
5
by: Wonder | last post by:
How can I create or use the msgobx to show a message without a default button. The user has explicity to click on the button, so the msgbox closes it. Thanks,
10
by: cj | last post by:
Here's an easy one, I hope. How do I make button1, which I put on this form from the toolbox, the default button on the form? I thought it used to be a property in the properties window called...
3
by: Rick Brandt | last post by:
I am using some buttons to hide/show various divs and am changing the style of the button to indicate which button's view is "active". My problem is that for the non-active buttons I want the...
3
by: Anil Kumar Sharma | last post by:
Hello, I am working on C# using vs.net 2003. I have faced two interesting problems. 1. Dynamically setting Default Button: I created a form and used it in various contexts. On basis of the...
15
by: simonoficina | last post by:
Hello all! I am a vb.net beginner in Spain. When I use VB6 ,the button object has a property called "default" that can set this button like press "ENTER" key. But in the VB.net I can't find this...
4
by: Whasigga | last post by:
Hi I've created a form that has 7 subforms. It is the same subform, bound to a table, just repeated. This form represents a week, and each subform is used to enter in data for each day of the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.