I am trying to save all the controls from one WebForm using a serialized Dictionary (controlId - string, controlValue - string). Next i want to deserialize that Dictionary and dynamically fill the controls with their values.
The problem is that some of my controls have AutoPostBack true and also event handlers. Is there a way to dynamically call these event handlers? I want to avoid another switch by control's id.
Ex:
foreach (KeyValuePair<string, string> kvp in dict)
{
Control c = findControlRecursive(Page, kvp.Key);
if (c != null)
{
switch (c.GetType().Name)
{
case "TextBox":
((TextBox)c).Text = kvp.Value;
if (((TextBox)c).AutoPostBack) .......
EDIT:
Let's say that I have 10 different forms. each has about 50 controls. I want to add/edit a set of data. I try to avoid tables in database with columns for each control, that's why I want to use serialization.