Dictionary<string,string> controlInfo=new Dictionary<string,string>();
foreach (Control control in Page.Controls)
{
/* storing client id in view state
* if you want to put more information of control, use custom object instead of string
*/
if(!string.IsNullOrEmpty(control.ID))
controlInfo.Add(control.ID,control.ClientID);
}
ViewState["controlInfo"]=controlInfo;
You can use above code block to store the control information in view state.If you have controls in control, you need to build a recursive algorithm to get all the controll information.If you want to retrive control information from the view state, use the following code block.
Dictionary<string, string> controlInfo = ViewState["controlInfo"] as Dictionary<string, string>;
Dictionary<string,string>.Enumerator enumerator=controlInfo.GetEnumerator();
while (enumerator.MoveNext())
{
Label1.Text += enumerator.Current.Value;
}