Howdy,
-- BEGIN CODE --
public static void SetFocus(Control control)
{
System.Text.StringBuilder script = new System.Text.StringBuilder();
script.Append("\r\n<script language='JavaScript'>\r\n");
script.Append("<!--\r\n");
script.Append("function OnWindowLoad()\r\n");
script.Append("{\r\n");
script.Append("\tdocument.");
Control parent = control.Parent;
// get parent form id
while (!(parent is System.Web.UI.HtmlControls.HtmlForm))
parent = parent.Parent;
script.Append(parent.ClientID);
script.Append("['");
script.Append(control.UniqueID);
script.Append("'].focus();\r\n");
script.Append("}\r\n");
script.Append("window.onload = OnWindowLoad;\r\n");
script.Append("// -->\r\n");
script.Append("</script>");
control.Page.RegisterClientScriptBlock("SetFocusScript",
script.ToString());
}
-- END CODE --