Friday, 11 July 2008

Recursively find control from previous page

hi

i study more time asp.net starter kit and i found best code for finding previous page server control.

But from prevoius page you must use postbackurl on button or use server.transfer("go.aspx");

The code is follow........

public sealed class Util{

private Util(){}

public static Control FindControlRecursively(string controlID, ControlCollection controls){

if (controlID == null || controls == null)

return null;

foreach (Control c in controls){
if (c.ID == controlID)
return c;
if (c.HasControls()){
Control inner = FindControlRecursively(controlID, c.Controls);
if (inner != null)
return inner;}
}

return null;
}
Share:

0 Comments:

Post a Comment