G
George Durzi
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?
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?