472,143 Members | 1,136 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,143 software developers and data experts.

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

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
5 22858
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
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
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
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
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.

Similar topics

6 posts views Thread by Alex | last post: by
7 posts views Thread by Jan Hoffman | last post: by
6 posts views Thread by John Smith | last post: by
reply views Thread by sunilthk | last post: by
5 posts views Thread by Stuart Shay | last post: by

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.