Does u ever feel boring when u try clear all field in web-page.V can simply avoid that by using a one time effort
here i created a function u call the when ever u need.
Function
public static void ClearFields(ControlCollection pageControls)
{
foreach (Control contl in pageControls)
{
string strCntName = (contl.GetType()).Name;
switch (strCntName)
{
case "TextBox":
TextBox tbSource = (TextBox)contl;
tbSource.Text = "";
break;
case "RadioButtonList":
RadioButtonList rblSource = (RadioButtonList)contl;
rblSource.SelectedIndex = -1;
break;
case "DropDownList":
DropDownList ddlSource = (DropDownList)contl;
ddlSource.SelectedIndex = -1;
break;
case "ListBox":
ListBox lbsource = (ListBox)contl;
lbsource.SelectedIndex = -1;
break;
}
ClearFields(contl.Controls);
}
}
Call the function
Now i will give u small documentaion how it workz. It will find all the textbox, Radiobutton list,Dropdown, Listbox On the webpage 'n make to default postion.
Hope It help u some ways
Have a nice day... 'N happy Coding :)
No comments:
Post a Comment