TextChanged Asp.net question

B

barry

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
 
H

Herfried K. Wagner [MVP]

barry said:
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>
 
B

barry

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
 
G

Greg Burns

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top