Click here to Skip to main content
15,897,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello,

i want to clear my all screen after save data, for that i find a code but i dont know how can i call this function in my button save.please advice

SQL
Public Sub ResetControl(ByVal mypage As Page)
       Dim myForm As Control = mypage.FindControl("Form")
       For Each ctrl As Control In myForm.Controls
           'Clears TextBox
           If TypeOf ctrl Is System.Web.UI.WebControls.TextBox Then
               TryCast(ctrl, TextBox).Text = String.Empty
           End If


           'Clears DropDown Selection
           If TypeOf ctrl Is System.Web.UI.WebControls.DropDownList Then
               TryCast(ctrl, DropDownList).ClearSelection()
           End If


           'Clears ListBox Selection
           If TypeOf ctrl Is System.Web.UI.WebControls.ListBox Then
               TryCast(ctrl, ListBox).ClearSelection()
           End If


           'Clears CheckBox Selection
           If TypeOf ctrl Is System.Web.UI.WebControls.CheckBox Then
               TryCast(ctrl, CheckBox).Checked = False
           End If


           'Clears RadioButton Selection


           If TypeOf ctrl Is System.Web.UI.WebControls.RadioButtonList Then
               TryCast(ctrl, RadioButtonList).ClearSelection()
           End If


           'Clears CheckBox Selection
           If TypeOf ctrl Is System.Web.UI.WebControls.CheckBoxList Then
               TryCast(ctrl, CheckBoxList).ClearSelection()
           End If


           If TypeOf ctrl Is System.Web.UI.WebControls.GridView Then
               TryCast(ctrl, GridView).Columns.Clear()
           End If

       Next




   End Sub



i used to call the below code in button click mode. but i am getting error. please advice

Protected Sub btnSaveReq_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSaveReq.Click

ResetControl()

end sub
Posted
Comments
MugiwaraUK 29-May-12 8:07am    
You need to run that method?

1 solution

VB
Protected Sub btnSaveReq_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSaveReq.Click

' TODO: Add your save code here



ResetControl(Me.Page)

end sub
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900