How do I reset form values in Microsoft Visual Studio 2008 Professional Edition

Status
Not open for further replies.

Patrick.Kershner

Solid State Member
Messages
9
Location
Colorado Springs
Hello I am tring to create a form and I need to add a "reset" button to the form incase people make a mistake. The code i have so far is:

Public Partial Class WebForm1
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

End Sub

Protected Sub Color_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles Adults.SelectedIndexChanged
message4.Text = "" 'initialize Text property
Select Case Adults.SelectedItem.Text
Case "0"
message4.Text &= "No Adults"

Case "1"
message4.Text &= "1 Adult"

Case "2"
message4.Text &= "2 Adults"

Case "3"
message4.Text &= "3 Adults"

Case "4"

message4.Text &= "4 Adults"

Case "5"

message4.Text &= "5 Adults"

Case "Else"

message4.Text &= "You did not choose!"

End Select

End Sub


Protected Sub full_name_TextChanged(ByVal sender As Object, ByVal e As EventArgs) Handles full_name.TextChanged
message2.Text &= full_name.Text


End Sub

Protected Sub email_TextChanged(ByVal sender As Object, ByVal e As EventArgs) Handles email.TextChanged
message8.Text &= email.Text
End Sub

Protected Sub children_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles children.SelectedIndexChanged
message5.Text = "" 'initialize Text property
Select Case children.SelectedItem.Text
Case "0"
message5.Text &= "No Children "

Case "1"
message5.Text &= "1 Child "

Case "2"
message5.Text &= "2 Children"

Case "3"
message5.Text &= "3 Children"

Case "4"

message5.Text &= "4 Children "

Case "5"

message5.Text &= "5 Children "

Case "Else"

message5.Text &= "You did not choose!"

End Select
End Sub

Protected Sub attend_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles attend.SelectedIndexChanged
message3.Text &= attend.Text
End Sub


Protected Sub address1_TextChanged1(ByVal sender As Object, ByVal e As EventArgs) Handles address1.TextChanged
message7.Text &= full_name.Text
message6.Text &= address1.Text
End Sub

Protected Sub apt_TextChanged(ByVal sender As Object, ByVal e As EventArgs) Handles apt.TextChanged
message9.Text &= apt.Text
End Sub

Protected Sub city_TextChanged(ByVal sender As Object, ByVal e As EventArgs) Handles city.TextChanged
message10.Text &= city.Text
End Sub

Protected Sub state_TextChanged(ByVal sender As Object, ByVal e As EventArgs) Handles state.TextChanged
message11.Text &= state.Text
End Sub

Protected Sub zip_TextChanged(ByVal sender As Object, ByVal e As EventArgs) Handles zip.TextChanged
message12.Text &= zip.Text
End Sub
End Class

Which is all working except if you try to correct the name it doenst clear out the data thats there and it adds it to the end. like this:
Confirm Information:
Patrick KershnerPatrick W Kershner + 2 Adults and 2 Children

Attending: Yes, I will attend

Email Address: none@none.com

Address:
Patrick Kershner
Test addy
nowhere town ,none 12345
And when I research for a reset button there seems to be no documentation on it and i have tried the tradition HTML reset code and still doesnt work.

I would like one of 2 solutions,

1) A reset button
or
2) A code to wipe out the current value, and replace with new value.

I am not sure if thats going to work or not but hey its worth a try, yall helped me with a JAVASCRIPT code for some radio buttons lol...

Well thanks in advance
 
Hello everyone, I figured it out. In order for me to clear the messages that was there i needed to add the following line of code:

message[insert number].Text = ""

That way when you refresh the new vaule will show
 
Status
Not open for further replies.
Back
Top Bottom