473,486 Members | 2,277 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Two text boxes each with their own button

I have a big problem. I have two text boxes each with their own own button.
Buton1 is for Textbox1 and Button2 is for Textbox2. Here's the problem, if
someone enters something into Textbox1, then enters something into Textbox2,
then hits their return key Button1 is called not Button2. This also happens
if they press Button2... Button1 is still called. Now, if they don't enter
anything into Textbox1 then Button2 is called when they enter something into
Textbox2 and hit return or press Button2.

Both textboxes have postback off (I also tried with on but that caused it to
submit twice).

Is there away around this or am I supposed to figure out some javascript to
empty Textbox1 when someone clicks on Textbox2?
Nov 18 '05 #1
4 927
1) catch the button click in the code-behind instead of using the page_load
with an IsPostBack
2) use clientside code to catch the textbox's key_down event, specifying the
enter key, and have it "push" the appropriate button.

I'm sure there are other ideas, those are just the first two I had.

--
Curt Christianson
Owner/Lead Developer, DF-Software
www.Darkfalz.com
"Greg" <no****@nospam.com> wrote in message
news:OQ**************@TK2MSFTNGP09.phx.gbl...
I have a big problem. I have two text boxes each with their own own button. Buton1 is for Textbox1 and Button2 is for Textbox2. Here's the problem, if someone enters something into Textbox1, then enters something into Textbox2, then hits their return key Button1 is called not Button2. This also happens if they press Button2... Button1 is still called. Now, if they don't enter anything into Textbox1 then Button2 is called when they enter something into Textbox2 and hit return or press Button2.

Both textboxes have postback off (I also tried with on but that caused it to submit twice).

Is there away around this or am I supposed to figure out some javascript to empty Textbox1 when someone clicks on Textbox2?

Nov 18 '05 #2
"Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
news:O8**************@TK2MSFTNGP09.phx.gbl...
1) catch the button click in the code-behind instead of using the page_load with an IsPostBack
2) use clientside code to catch the textbox's key_down event, specifying the enter key, and have it "push" the appropriate button.

I'm sure there are other ideas, those are just the first two I had.

--
Curt Christianson
Owner/Lead Developer, DF-Software
www.Darkfalz.com


Thanks for the quick reply. I am using code behind for both click events.
Is there away I can find out which textbox the return key was pressed on in
code behind?
Nov 18 '05 #3
the Request.Form will get you this I believe. Do a IF check for button1, if
it's there it was clicked, if it wasn't then check for Button2.

--
Curt Christianson
Owner/Lead Developer, DF-Software
www.Darkfalz.com
"Greg" <no****@nospam.com> wrote in message
news:Ox**************@TK2MSFTNGP10.phx.gbl...
"Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
news:O8**************@TK2MSFTNGP09.phx.gbl...
1) catch the button click in the code-behind instead of using the page_load
with an IsPostBack
2) use clientside code to catch the textbox's key_down event, specifying

the
enter key, and have it "push" the appropriate button.

I'm sure there are other ideas, those are just the first two I had.

--
Curt Christianson
Owner/Lead Developer, DF-Software
www.Darkfalz.com


Thanks for the quick reply. I am using code behind for both click events.
Is there away I can find out which textbox the return key was pressed on

in code behind?

Nov 18 '05 #4
"Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
news:uS**************@TK2MSFTNGP09.phx.gbl...
the Request.Form will get you this I believe. Do a IF check for button1, if it's there it was clicked, if it wasn't then check for Button2.

--
Curt Christianson
Owner/Lead Developer, DF-Software
www.Darkfalz.com


Unfortunately, when the user hits the enter on Textbox2 Button1 click event
is called. Nothing in the Request.Form about Button2. I did notice that
when I click on Textbox1 focus is set on Button1, but if I click on Textbox2
focus is not set on Button2. So, the default button is apparently Button1,
but that's a problem if I can't specify which textbox goes with which
button.

I found some client-side code to set the return event for the Textbox's but
it was VBScript so it didn't work with Mozilla browser and I also needed to
change the Textbox from a webform control to an html control, which I'd
prefer not to do.
Nov 18 '05 #5

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

Similar topics

1
3714
by: Daniel Hill | last post by:
OK, I have very, VERY basic background knowledge of VB6 and have now upgraded to VB.NET and now I'm struggling to bring up the forms I want. What I am looking to do is to have a click a command...
11
3843
by: DP | last post by:
hi, i have a films table and form. i have a txt field in teh form called txtSearch , and i;ve created a query with all the film table fields in it. how can i get the query to load up, wth the...
3
3962
by: acecraig100 | last post by:
I am fairly new to Javascript. I have a form that users fill out to enter an animal to exhibit at a fair. Because we have no way of knowing, how many animals a user may enter, I created a table...
7
4496
by: ljungers | last post by:
Have Form-1 with 3 text boxes and 1 command button. With any of the 3 boxes filled out and button is clicked, a Macro is performed that Opens a Query that has a WHERE clause that uses the 3 test...
12
9750
by: ljungers | last post by:
I'm on the home streach of my project and found that my "Reset for New Search" command button not working as desired. What should happen is that when the button is clicked a Event Procedure is run....
33
2222
JamesDC
by: JamesDC | last post by:
Hey all, I'm working with Access 2002. I'm working on an inherited access file and I'm trying to figure out how the text boxes work in order to try and fix a bug which occurs. The situation is...
4
2261
by: Andrew Meador - ASCPA, MCSE, MCP+I, Network+, A+ | last post by:
I have created a report. This report needs to display records between two dates entered by the user. I put two text boxes on the report so I can enter the start and end date - I set them to use an...
1
4867
by: semomaniz | last post by:
I have a form where i have created the form dynamically. First i manually added a panel control to the web page. Then i added another panel dynamically and inside this panel i created tables. I have...
9
2068
by: RICHARD BROMBERG | last post by:
Please bear in mind that I am a newbie. I am posting this question a second time because the responses to my earlier post were a little wide of the mark. So, here goes: I am using Access 2000...
11
5140
by: jwessner | last post by:
I have a form (Form1) which contains basic Project data and a subform listing the personnel assigned to the Project as a continuous form. Selecting a person on that project and clicking on a command...
0
6967
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
7132
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
7180
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...
1
6846
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...
0
5439
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3076
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3071
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
600
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
266
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.