469,296 Members | 2,074 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,296 developers. It's quick & easy.

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 22653
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
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.