Tuesday, October 26, 2004

maintain scroll position

///


/// Registers a _javascript method that will bring the focus of the page
/// to a specific control when the page loads.
///

/// The ID of the control to focus on.
/// The page the control belongs to.
public static void RegisterControlFocusScript(string controlID, Page
target)
{
string script = "\r\n\r\n " function focus() {\r\n" +
" var target;\r\n" +
" target = document.getElementById('" +
controlID + "');\r\n" +
" if (target != null) {\r\n" +
" target.focus();\r\n" +
" }\r\n" +
" }\r\n" +
" window.onfiltered=focus;\r\n" +
"\r\n";

target.RegisterClientScriptBlock("focus", script);
}

0 Comments:

Post a Comment

<< Home