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

TextChanged Asp.net question

P: n/a
The code below works fine for one textbox (hit enter key) but adding another
textbox and including the handle for it will not change either textbox
without switching the focus to say a button. Do not understand the concept
why it works for one but not two boxes.
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles TextBox1.TextChanged

Dim txt As TextBox = CType(sender, TextBox)

txt.Text = txt.Text.ToUpper

End Sub
Nov 21 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
"barry" <fl******@ix.netcom.com> schrieb:
The code below works fine for one textbox (hit enter key) but adding
another
textbox and including the handle for it will not change either textbox
without switching the focus to say a button. Do not understand the concept
why it works for one but not two boxes.
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles TextBox1.TextChanged

Dim txt As TextBox = CType(sender, TextBox)

txt.Text = txt.Text.ToUpper


Is this the complete code?

Short but complete programs
<URL:http://yoda.arachsys.com/csharp/complete.html>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #2

P: n/a
I will state my question again related to the code that follows:

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles TextBox1.TextChanged, TextBox2.TextChanged
Dim txt As TextBox = CType(sender, TextBox)

txt.Text = txt.Text.ToUpper

End Sub

When there is a button on the webform along with the above two textboxes the
code above will execute when I hit the enter key in each textbox
Why, When I remove the button on the form and hit the enter key in each
textbox nothng happens?

thanks


"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:OK**************@TK2MSFTNGP12.phx.gbl...
"barry" <fl******@ix.netcom.com> schrieb:
The code below works fine for one textbox (hit enter key) but adding
another
textbox and including the handle for it will not change either textbox
without switching the focus to say a button. Do not understand the concept why it works for one but not two boxes.
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

Dim txt As TextBox = CType(sender, TextBox)

txt.Text = txt.Text.ToUpper


Is this the complete code?

Short but complete programs
<URL:http://yoda.arachsys.com/csharp/complete.html>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #3

P: n/a
Your button is causing a post back, allowing this server side event to
execute.

Without the button, no postback and hence no server side code will ever
execute.

I suggest posting to microsoft.public.dotnet.framework.aspnet group for more
responses.

Greg

"barry" <fl******@ix.netcom.com> wrote in message
news:ev**************@TK2MSFTNGP11.phx.gbl...
I will state my question again related to the code that follows:

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles TextBox1.TextChanged, TextBox2.TextChanged
Dim txt As TextBox = CType(sender, TextBox)

txt.Text = txt.Text.ToUpper

End Sub

When there is a button on the webform along with the above two textboxes
the
code above will execute when I hit the enter key in each textbox
Why, When I remove the button on the form and hit the enter key in each
textbox nothng happens?

thanks


"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:OK**************@TK2MSFTNGP12.phx.gbl...
"barry" <fl******@ix.netcom.com> schrieb:
> The code below works fine for one textbox (hit enter key) but adding
> another
> textbox and including the handle for it will not change either textbox
> without switching the focus to say a button. Do not understand the concept > why it works for one but not two boxes.
> Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As > System.EventArgs) Handles TextBox1.TextChanged
>
> Dim txt As TextBox = CType(sender, TextBox)
>
> txt.Text = txt.Text.ToUpper


Is this the complete code?

Short but complete programs
<URL:http://yoda.arachsys.com/csharp/complete.html>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>


Nov 21 '05 #4

P: n/a
Greg/Barry,

Or you have to set the autopostback to true

http://msdn.microsoft.com/library/de...tBackTopic.asp

:-)

Just to be sure we are talking about the same

Cor

"Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com>
Your button is causing a post back, allowing this server side event to
execute.

Without the button, no postback and hence no server side code will ever
execute.

I suggest posting to microsoft.public.dotnet.framework.aspnet group for
more responses.

Greg

"barry" <fl******@ix.netcom.com> wrote in message
news:ev**************@TK2MSFTNGP11.phx.gbl...
I will state my question again related to the code that follows:

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e
As
System.EventArgs) Handles TextBox1.TextChanged, TextBox2.TextChanged
Dim txt As TextBox = CType(sender, TextBox)

txt.Text = txt.Text.ToUpper

End Sub

When there is a button on the webform along with the above two textboxes
the
code above will execute when I hit the enter key in each textbox
Why, When I remove the button on the form and hit the enter key in each
textbox nothng happens?

thanks


"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:OK**************@TK2MSFTNGP12.phx.gbl...
"barry" <fl******@ix.netcom.com> schrieb:
> The code below works fine for one textbox (hit enter key) but adding
> another
> textbox and including the handle for it will not change either textbox
> without switching the focus to say a button. Do not understand the

concept
> why it works for one but not two boxes.
> Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal
> e

As
> System.EventArgs) Handles TextBox1.TextChanged
>
> Dim txt As TextBox = CType(sender, TextBox)
>
> txt.Text = txt.Text.ToUpper

Is this the complete code?

Short but complete programs
<URL:http://yoda.arachsys.com/csharp/complete.html>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>



Nov 21 '05 #5

P: n/a
Thanks to all - the autopostback did the trick
"Cor Ligthert" <no************@planet.nl> wrote in message
news:Os**************@tk2msftngp13.phx.gbl...
Greg/Barry,

Or you have to set the autopostback to true

http://msdn.microsoft.com/library/de...tBackTopic.asp
:-)

Just to be sure we are talking about the same

Cor

"Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com>
Your button is causing a post back, allowing this server side event to
execute.

Without the button, no postback and hence no server side code will ever
execute.

I suggest posting to microsoft.public.dotnet.framework.aspnet group for
more responses.

Greg

"barry" <fl******@ix.netcom.com> wrote in message
news:ev**************@TK2MSFTNGP11.phx.gbl...
I will state my question again related to the code that follows:

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e
As
System.EventArgs) Handles TextBox1.TextChanged, TextBox2.TextChanged
Dim txt As TextBox = CType(sender, TextBox)

txt.Text = txt.Text.ToUpper

End Sub

When there is a button on the webform along with the above two textboxes the
code above will execute when I hit the enter key in each textbox
Why, When I remove the button on the form and hit the enter key in each
textbox nothng happens?

thanks


"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:OK**************@TK2MSFTNGP12.phx.gbl...
"barry" <fl******@ix.netcom.com> schrieb:
> The code below works fine for one textbox (hit enter key) but adding
> another
> textbox and including the handle for it will not change either textbox > without switching the focus to say a button. Do not understand the
concept
> why it works for one but not two boxes.
> Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal > e
As
> System.EventArgs) Handles TextBox1.TextChanged
>
> Dim txt As TextBox = CType(sender, TextBox)
>
> txt.Text = txt.Text.ToUpper

Is this the complete code?

Short but complete programs
<URL:http://yoda.arachsys.com/csharp/complete.html>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>



Nov 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.