darrel wrote:
I have a 'cancel' button that should reload the current page. Ie, reset the
page back to it's initial state.
Is the best way to do this to simply have the event handler for that button
redirect the page to itself?
If so, is there a short-and-sweet way to write that out? Or do I need to
first grab the URL and parse it?
I don't want to hardcore the url as this might be used in different
locations.
-Darrel
Hello,
Hope this helps (see attached text file)
ChiefDnd
Private Sub btnCancel_Reset _Click(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles btnCancel_Reset .Click
'/////////////////////////////////////////////////////////////////
' Clear the form (Textbox and DropDownList)
'/////////////////////////////////////////////////////////////////
Dim objC As Control
For Each objC In Page.Controls
Dim objType As Type = objC.GetType()
If objType.FullNam e = "System.Web.UI. HtmlControls.Ht mlForm" Then
Dim objF As HtmlForm = CType(objC, HtmlForm)
Dim objWC As Control
For Each objWC In objF.Controls
Dim objWCType As Type = objWC.GetType()
If objWCType.FullN ame = "System.Web.UI. WebControls.Tex tBox" Then
Dim objTB As TextBox = CType(objWC, TextBox)
objTB.Text = ""
End If
If objWCType.FullN ame = "System.Web.UI. WebControls.Dro pDownList" Then
Dim objDDL As DropDownList = CType(objWC, DropDownList)
objDDL.Selected Index = 0
End If
Next objWC
End If
Next objC
lblMessage.Visi ble = False
'/////////////////////////////////////////////////////////////////
' Refill the form as needed
'/////////////////////////////////////////////////////////////////
SetupPage()
End Sub