Create your own control that inherits, for example, a literal. This control will be an assistant.
You enter it on the page, do all the dirty work for you. for example, the output code [which will take a long time to write] based on some logic and after you are done with it.
( , ), , , .
, , , , - , , .
, .
[ ], , , !
, .
public class ValidationCodeProducerHelper : Literal
{
public string MyValidationGroup { get; set; }
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
ControlCollection _collection = Page.Controls;
Text = GetCode(_collection).Replace("\r\n", "<br/>");
}
private string GetCode(Control _control)
{
StringBuilder _output = new StringBuilder();
if (_control.GetType().GetProperty("ValidationGroup") != null && !string.IsNullOrEmpty(_control.ID))
{
_output.AppendFormat("{0}.{1} = {2};", _control.ID, "ValidationGroup", MyValidationGroup);
_output.AppendLine();
}
_output.Append(GetCode(_control.Controls));
return _output.ToString();
}
private string GetCode(ControlCollection _collection)
{
StringBuilder _output = new StringBuilder();
foreach (Control _control in _collection)
{
_output.Append(GetCode(_control));
}
return _output.ToString();
}
}