Not really umbraco related more .net related, so what you would need is code behind for the master template for the page that contains the usercontrols, then in that code behind do a recursive look for all the fields and then get their values,
/// <summary>/// get find control method using generics/// </summary>/// <typeparam name="T">type of item you want</typeparam>/// <param name="ancestor">parent to start looking from</param>/// <returns>collection of T items</returns>publicstaticList<T>ControlsByTypeUsingAncestor<T>(Controlancestor)whereT:Control{varcontrols=newList<T>();//Append to search results if we match the type if(typeof(T).IsAssignableFrom(ancestor.GetType())){controls.Add((T)ancestor);}//Recurse into child controls foreach(Controlctrlinancestor.Controls){controls.AddRange(ControlsByTypeUsingAncestor<T>(ctrl));}returncontrols;}
so you could do something like
var textboxes = ControlsByTypeUsingAncestor<TextBox>(this);
where this is the current master page object, so the code will recursively get you all textboxes on the current page, you can repeat for other controls.
Getting data/input from several User Controls?
Hi all. I have Googled this a lot without success. Plese help.
I want to collect the user input from several User Controls and process the input in code behind.
Is that possible??
David,
Not really umbraco related more .net related, so what you would need is code behind for the master template for the page that contains the usercontrols, then in that code behind do a recursive look for all the fields and then get their values,
so you could do something like
var textboxes = ControlsByTypeUsingAncestor<TextBox>(this);
where this is the current master page object, so the code will recursively get you all textboxes on the current page, you can repeat for other controls.
Regards
Ismail
is working on a reply...