By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,739 Members | 2,059 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,739 IT Pros & Developers. It's quick & easy.

asp:TextBox - TextChange Event (Enter Key Does Not Work)

P: n/a
PD
The TextChanged event is not being called when I hit the "Enter" key.
Yet it does for the "Tab" key. I set a break point in the Page_Load
event and the TextChanged event and none of these get called when I
hit the 'Enter' key. After typing in letters in the textbox, if I hit
the 'Tab' key or click outside the text box with my mouse, the event
fires.

Here's the code:

<form id="frmArticle" name="frmArticle" method="post" runat="server">
.......
.......
<asp:textbox id="txtSearchCriteria"
OnTextChanged="txtSearchCriteria_TextChanged" runat="server"
AutoPostBack=True></asp:textbox></input>&nbsp;&nbsp;
.......
.......
</form>

Here's the procedure code:

Sub txtSearchCriteria_TextChanged(ByVal sender As System.Object, ByVal
e As System.EventArgs)
Try
FindArticles()
blnSearch = True
Catch ex As Exception
Throw ex
End Try
End Sub
Any suggestions would be greatly appreciated!
Pat
Nov 18 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
TextChanged is fired when the control loses focus...hitting enter doesn't
change focus..hitting tab moves the cursor to the next item, thus it loses
focus...

karl

"PD" <pd*****@commonwealth.com> wrote in message
news:9d**************************@posting.google.c om...
The TextChanged event is not being called when I hit the "Enter" key.
Yet it does for the "Tab" key. I set a break point in the Page_Load
event and the TextChanged event and none of these get called when I
hit the 'Enter' key. After typing in letters in the textbox, if I hit
the 'Tab' key or click outside the text box with my mouse, the event
fires.

Here's the code:

<form id="frmArticle" name="frmArticle" method="post" runat="server">
......
......
<asp:textbox id="txtSearchCriteria"
OnTextChanged="txtSearchCriteria_TextChanged" runat="server"
AutoPostBack=True></asp:textbox></input>&nbsp;&nbsp;
......
......
</form>

Here's the procedure code:

Sub txtSearchCriteria_TextChanged(ByVal sender As System.Object, ByVal
e As System.EventArgs)
Try
FindArticles()
blnSearch = True
Catch ex As Exception
Throw ex
End Try
End Sub
Any suggestions would be greatly appreciated!
Pat

Nov 18 '05 #2

P: n/a
asp.net form doesnot automatically submit on key press enter key.
change event is fired on onLostFocus and causes the focus to move from
current control to the next control then it fires the changed event then.

hth

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"PD" <pd*****@commonwealth.com> wrote in message
news:9d**************************@posting.google.c om...
The TextChanged event is not being called when I hit the "Enter" key.
Yet it does for the "Tab" key. I set a break point in the Page_Load
event and the TextChanged event and none of these get called when I
hit the 'Enter' key. After typing in letters in the textbox, if I hit
the 'Tab' key or click outside the text box with my mouse, the event
fires.

Here's the code:

<form id="frmArticle" name="frmArticle" method="post" runat="server">
......
......
<asp:textbox id="txtSearchCriteria"
OnTextChanged="txtSearchCriteria_TextChanged" runat="server"
AutoPostBack=True></asp:textbox></input>&nbsp;&nbsp;
......
......
</form>

Here's the procedure code:

Sub txtSearchCriteria_TextChanged(ByVal sender As System.Object, ByVal
e As System.EventArgs)
Try
FindArticles()
blnSearch = True
Catch ex As Exception
Throw ex
End Try
End Sub
Any suggestions would be greatly appreciated!
Pat

Nov 18 '05 #3

P: n/a
PD
So how could I get the enter key to kick off an event on the code
behind? The function I'm trying to get to work is a search page. When
user's type in a search filter and hit 'Enter' I would like that to
trigger the code that returns the result data to the page. Thoughts?
Thanks again!

"Hermit Dave" <he************@CAPS.AND.DOTS.hotmail.com> wrote in message news:<OY**************@TK2MSFTNGP15.phx.gbl>...
asp.net form doesnot automatically submit on key press enter key.
change event is fired on onLostFocus and causes the focus to move from
current control to the next control then it fires the changed event then.

hth

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"PD" <pd*****@commonwealth.com> wrote in message
news:9d**************************@posting.google.c om...
The TextChanged event is not being called when I hit the "Enter" key.
Yet it does for the "Tab" key. I set a break point in the Page_Load
event and the TextChanged event and none of these get called when I
hit the 'Enter' key. After typing in letters in the textbox, if I hit
the 'Tab' key or click outside the text box with my mouse, the event
fires.

Here's the code:

<form id="frmArticle" name="frmArticle" method="post" runat="server">
......
......
<asp:textbox id="txtSearchCriteria"
OnTextChanged="txtSearchCriteria_TextChanged" runat="server"
AutoPostBack=True></asp:textbox></input>&nbsp;&nbsp;
......
......
</form>

Here's the procedure code:

Sub txtSearchCriteria_TextChanged(ByVal sender As System.Object, ByVal
e As System.EventArgs)
Try
FindArticles()
blnSearch = True
Catch ex As Exception
Throw ex
End Try
End Sub
Any suggestions would be greatly appreciated!
Pat

Nov 18 '05 #4

P: n/a
PD
Found a solution... Added onkeypress="return(submitForm());" to the
asp:text control. SubmitForm code..

function submitForm()
{
if (event.keyCode == 13)
{
frmArticle.submit();
}
}
</script>

Then when return key is pressed, the form submits. Appears to work
fine so far.

"Hermit Dave" <he************@CAPS.AND.DOTS.hotmail.com> wrote in message news:<OY**************@TK2MSFTNGP15.phx.gbl>...
asp.net form doesnot automatically submit on key press enter key.
change event is fired on onLostFocus and causes the focus to move from
current control to the next control then it fires the changed event then.

hth

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"PD" <pd*****@commonwealth.com> wrote in message
news:9d**************************@posting.google.c om...
The TextChanged event is not being called when I hit the "Enter" key.
Yet it does for the "Tab" key. I set a break point in the Page_Load
event and the TextChanged event and none of these get called when I
hit the 'Enter' key. After typing in letters in the textbox, if I hit
the 'Tab' key or click outside the text box with my mouse, the event
fires.

Here's the code:

<form id="frmArticle" name="frmArticle" method="post" runat="server">
......
......
<asp:textbox id="txtSearchCriteria"
OnTextChanged="txtSearchCriteria_TextChanged" runat="server"
AutoPostBack=True></asp:textbox></input>&nbsp;&nbsp;
......
......
</form>

Here's the procedure code:

Sub txtSearchCriteria_TextChanged(ByVal sender As System.Object, ByVal
e As System.EventArgs)
Try
FindArticles()
blnSearch = True
Catch ex As Exception
Throw ex
End Try
End Sub
Any suggestions would be greatly appreciated!
Pat

Nov 18 '05 #5

P: n/a
well you could manually trap the enter key using javascript and call same
clientside code as the onLostFocus

but its not a clean way to do it.. and i just disable enter key.. ie do
nothing if enter key is pressed.

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"PD" <pd*****@commonwealth.com> wrote in message
news:9d**************************@posting.google.c om...
Found a solution... Added onkeypress="return(submitForm());" to the
asp:text control. SubmitForm code..

function submitForm()
{
if (event.keyCode == 13)
{
frmArticle.submit();
}
}
</script>

Then when return key is pressed, the form submits. Appears to work
fine so far.

"Hermit Dave" <he************@CAPS.AND.DOTS.hotmail.com> wrote in message

news:<OY**************@TK2MSFTNGP15.phx.gbl>...
asp.net form doesnot automatically submit on key press enter key.
change event is fired on onLostFocus and causes the focus to move from
current control to the next control then it fires the changed event then.
hth

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"PD" <pd*****@commonwealth.com> wrote in message
news:9d**************************@posting.google.c om...
The TextChanged event is not being called when I hit the "Enter" key.
Yet it does for the "Tab" key. I set a break point in the Page_Load
event and the TextChanged event and none of these get called when I
hit the 'Enter' key. After typing in letters in the textbox, if I hit
the 'Tab' key or click outside the text box with my mouse, the event
fires.

Here's the code:

<form id="frmArticle" name="frmArticle" method="post" runat="server">
......
......
<asp:textbox id="txtSearchCriteria"
OnTextChanged="txtSearchCriteria_TextChanged" runat="server"
AutoPostBack=True></asp:textbox></input>&nbsp;&nbsp;
......
......
</form>

Here's the procedure code:

Sub txtSearchCriteria_TextChanged(ByVal sender As System.Object, ByVal
e As System.EventArgs)
Try
FindArticles()
blnSearch = True
Catch ex As Exception
Throw ex
End Try
End Sub
Any suggestions would be greatly appreciated!
Pat

Nov 18 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.