Click here to Skip to main content
15,898,938 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Public Sub ClearTextBox(ByVal root As Control)
For Each ctrl As Control In root.Controls
ClearTextBox(ctrl)
If TypeOf ctrl Is TextBox Then
CType(ctrl, TextBox).Text = String.Empty
End If
Next ctrl
End Sub
Protected Sub btnClear_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnClear.Click
ClearTextBox(Me)
End Sub
Posted

1 solution

Hi,


VB
Public Sub ClearTextBox(ByVal root As Control)
For Each ctrl As Control In root.Controls
ClearTextBox(ctrl)
If TypeOf ctrl Is TextBox Then
CType(ctrl, TextBox).Text = String.Empty
End If
if typeof ctrl is DropDownList Then
cType(ctrl,DropDownList).SelectedIndex=0
End IF

Next ctrl
End Sub
Protected Sub btnClear_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnClear.Click
ClearTextBox(Me)
End Sub
 
Share this answer
 
Comments
akhil.krish 5-Jun-13 2:10am    
Hi Rockstar,

i try this code same problem.... dropdownlist value not clear.. i wan't click the drop then show the value...open form clear textbox and dropdownlist values.....
Rockstar_ 5-Jun-13 2:13am    
Do u want to clear the drop down list? or u want to select the default one?
akhil.krish 5-Jun-13 2:57am    
select default one
Rockstar_ 5-Jun-13 3:03am    
call this javascript function on button's onclient click event.

function JSFunctionValidate()
{
document.getElementById('<%=ddlView.ClientID%>').selectedIndex =0

}

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