Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Two text boxes each with their own button

Reply
Thread Tools

Two text boxes each with their own button

 
 
Greg
Guest
Posts: n/a
 
      02-04-2004
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?


 
Reply With Quote
 
 
 
 
Curt_C [MVP]
Guest
Posts: n/a
 
      02-04-2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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?
>
>



 
Reply With Quote
 
 
 
 
Greg
Guest
Posts: n/a
 
      02-04-2004
"Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
news:(E-Mail Removed)...
> 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?


 
Reply With Quote
 
Curt_C [MVP]
Guest
Posts: n/a
 
      02-04-2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
> news:(E-Mail Removed)...
> > 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?
>
>



 
Reply With Quote
 
Greg
Guest
Posts: n/a
 
      02-04-2004
"Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
news:(E-Mail Removed)...
> 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.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Two routers with their own external static public IP's serving PORTIONS of the same internal subnet. Is that OK barret bondon Cisco 3 04-25-2012 06:35 PM
Space between input boxes and selection boxes is not the same in Internet Explorer Stefan Mueller HTML 5 06-16-2009 02:06 PM
Prophets are honored by everyone, except the people of their hometownand their own family. Eljee Digital Photography 8 09-21-2006 05:35 AM
Re: Multiple IIS servers, each having their own process identity Steven Cheng[MSFT] ASP .Net 0 09-22-2005 08:19 AM
Two submit buttons, can each call its own action? Fernie HTML 9 12-05-2004 07:09 PM



Advertisments