by Pieter Brinkman
15. April 2009 02:56
Every time a form is successful summited I need to clear all input-fields to the default values and give feedback to the user. I wrote a method ClearControl that can have a control as input parameter. This method will set the control based on his type back to the defaultvalue.
public static void ClearControl(Control control)
{
switch (control.GetType().Name)
{
case "TextBox":
TextBox txtBox = (TextBox)control;
txtBox.Text = "";
break;
case "DropDownList":
DropDownList ddl = (DropDownList)control;
ddl.SelectedIndex = 0;
break;
case "CheckBox":
CheckBox chk = (CheckBox)control;
chk.Checked = false;
break;
case "CheckBoxList":
CheckBoxList chkList = (CheckBoxList)control;
foreach (ListItem li in chkList.Items)
li.Selected = false;
break;
case "Panel":
ClearFields((Panel)control);
break;
case "RadioButtonList":
RadioButtonList rbl = (RadioButtonList)control;
rbl.SelectedIndex = -1;
break;
}
}
To use this method I wrote a method 'ClearFields' that accepts a View or Container control. You can add every type of control that has the .Controls property.
public static void ClearFields(Panel container)
{
foreach (Control control in container.Controls)
{
ClearControl(control);
}
}
public static void ClearFields(View container)
{
foreach (Control control in container.Controls)
{
ClearControl(control);
}
}
When I have some time left I will try to implement the ClearFields Method as a ExtensionMethod.
Cheers,
Pieter
by Pieter Brinkman
25. June 2008 10:24
I've search them all up for a 1000 times. Now I'm going to write them down as reference. This post will grow in the next few months.
Remember do not forget to set the behaviorId of the control.
References:
CollapsiblePanelExtender
Expand:
-
$find('BehaviorId')._doOpen();
Collapse:
ModalPopupExtender
Show popup:
Hide popup:
by Pieter Brinkman
11. January 2008 06:03
When surfing around I found this great range ASP.Net controls. Obout.com offers a great variety of ASP and ASP .Net controls. The controls are Cross-Browser (including Safari and Opera).You can download the obout Suite for .Net 2.0. The suite contains the following controls:
-
TreeView (recommended)
-
Grid
-
Editor
-
Spell checker
-
Calendar
-
Easy menu
-
Combobox
-
Slide menu
-
AJAXPage
-
Two colors menu
-
Splitter
-
Super button
-
Tree_DB
-
Autosuggest
-
Show
-
Flyout Window
-
FileUploadProgress
-
Slide Panel (with Slide menu)
-
TabStrip (with Easy Menu)
-
Context menu (with EasyMenu)
-
Toolbar (with Supper button)
-
State Selector (with Combobox)
There are loads of examples on their website. So go check it out!