I am trying to polish up a program a program that I have converted from a Windows Form in to an ASP.NET Web Application. I have several questions:
1.) I have a drop down box where users can select their variables, but users can also enter their variables manually into various text fields. What I want is for the drop down box to show a string like “Choose Variables” when ever the user enters their variables manually. I want this to happen without having to reload the page.
2.) In the Windows Form version of this application I had a RichTextBox that populated with data (line by line) after a calculation was made. I used “AppendText” in my Windows Form, but that is not available in ASP.NET, and neither is the RichTextBox. I am open to suggestions here, I tried to use just a text box but that isn’t working right.
3.) In my Windows Form application I was using “KeyPress” events to prevent incorrect characters from being entered into the text fields. My code for these events looked similar to this:
Private Sub TextBox_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox.KeyPress
If (e.KeyChar < "0" OrElse e.KeyChar > "9") AndAlso e.KeyChar <> ControlChars.Back AndAlso e.KeyChar <> "." Then
e.Handled = True
End If
End Sub
How can I make this work again… also without reloading the page.
4.) This is not a major issue, but I would like all of the text to be selected when the cursor enters a field. In my Windows Form application I used “SelectAll”, but again, that is not available in ASP.NET
Thanks in advance.
1) You will have to do this in Javascript by changing the text of the dropdown or disabling it from the TextChanged event using something like this
2)You can use a Textbox with the TextMode set to MultiLine. Then you can use Textbox1.Text = Textbox1.Text & newString to append text to the end.
3) You can either do this in javascript or by using a regular expression validator (my suggestion).
4) Do this in javascript using something like this