/// Search for a control within the passed root control by the control id passed as string
///
/// the upper control to start to search for /// the id of the control as string ///
public static Control FindControlRecursive ( ref Control root, string id )
{
try
{
if ( root.ID == id )
{
return root;
} //eof if
for ( int i = 0 ; i < root.Controls.Count ; i++ ) { Control c = new Control ( ); c = root.Controls [i]; //Utils.Debugger.WriteIf ( "My c.Id.TosTring() is " + c.ID.ToString ( ) ); Control t = FindControlRecursive ( ref c, c.ID.ToString ( ) ); if ( t != null ) { return t; } //eof if } //eof foreach } //eof try catch ( Exception e ) { //Utils.Debugger.WriteIf ( "The following Exception occured : \n" + e.Message ); return null; } //eof catch return null; } //eof FindControlRecursive ///
/// Implements a row control finder based on the type of control and the control Id.
///
/// Type of the control. /// Name of the contains. ///
public static Control FindControlByTypeAndIdRecursively ( Control root, Type controlType, string id )
{
foreach (Control control in root.Controls)
{
if (control != null && control.HasControls () == true)
{
FindControlByTypeAndIdRecursively ( control, controlType, id );
}
else
{
if (control != null && control.GetType () == controlType && control.ID.Equals ( id ))
{
return control;
}
} //eof else
} //eof foreach
return null;
} //eof method
No comments:
Post a Comment
- the first minus - Comments have to be moderated because of the spammers
- the second minus - I am very lazy at moderating comments ... hardly find time ...
- the third minus - Short links are no good for security ...
- The REAL PLUS : Any critic and positive feedback is better than none, so your comments will be published sooner or later !!!!