TextChanged Asp.net question

  • Thread starter Thread starter barry
  • Start date Start date
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
 
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>
 
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
 
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
 
Back
Top