Re: Capturing Enter KeyDown in a TextBox
From: George Durzi (gdurzi_at_hotmail.com)
Date: 05/20/04
- Next message: ccurvey: "Re: I'm missing something simple"
- Previous message: John Lundrigan: "Copying files in the root with Copy Project"
- In reply to: hb: "Re: Capturing Enter KeyDown in a TextBox"
- Next in thread: hb: "Re: Capturing Enter KeyDown in a TextBox"
- Reply: hb: "Re: Capturing Enter KeyDown in a TextBox"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 20 May 2004 09:47:52 -0700
As I mentioned, by textbox and button are in a user control,
So I actually have to do KeyDownHandler('usercontrolname:btnCreateNewsFeed')
since that's how the element is being rendered.
And of course, as you suggested, with the
document.getElementById(btn).click();
It now works
Thank you
"hb" <hbranyan.SPAMBLOCK@merc.mercer.edu> wrote in message
news:2h45fmF8jhdqU1@uni-berlin.de...
> Think about the value you pass to the function. You are passing the ID of
> the btn, so you can't just call btn.click(); - that's the same as saying
> 'btnCreateNewsFeed'.click() and that will not work.
>
> Instead, replace btn.click(); with document.getElementById(btn).click();
>
>
> "George Durzi" <gdurzi@hotmail.com> wrote in message
> news:eDYCifoPEHA.1036@TK2MSFTNGP09.phx.gbl...
> > I have a text box and a button, and I want the enter key to run the
click
> > event of the button. The textbox and button are inside a user control. I
> > tried all sorts of stuff with the __EVENTTARGET hidden field with no
luck.
> >
> > Here's what I'm doing
> >
> > function KeyDownHandler(btn)
> > {
> > if (event.keyCode == 13)
> > {
> > event.returnValue=false;
> > event.cancel = true;
> > btn.click();
> > }
> > }
> >
> > <asp:TextBox ID="txtNewsFeedName" Runat="server" MaxLength="100"
> > Columns="35"
> onKeyDown="KeyDownHandler('btnCreateNewsFeed')"></asp:TextBox>
> > <asp:button ID="btnCreateNewsFeed" Runat="server" Text="Add"
> > CssClass="submitbutton" CausesValidation="False"></asp:button>
> >
> >
> >
> > When I hit Enter when typing inside the TextBox, the KeyDownHandler
> function
> > gets executed, but I get an error on the btn.click(); line.
> >
> > The error is: object doesn't support this property or method.
> >
> > Verified that btn is coming in as btnCreateNewsFeed. Dunno if you need
to
> do
> > casting in JavaScript, but how is this function supposed to know that
this
> > is a button...
> >
> > How can fire the click event of that button?
> >
> >
>
>
- Next message: ccurvey: "Re: I'm missing something simple"
- Previous message: John Lundrigan: "Copying files in the root with Copy Project"
- In reply to: hb: "Re: Capturing Enter KeyDown in a TextBox"
- Next in thread: hb: "Re: Capturing Enter KeyDown in a TextBox"
- Reply: hb: "Re: Capturing Enter KeyDown in a TextBox"
- Messages sorted by: [ date ] [ thread ]