In order to avoid conflict with others windows.onload calls I have modified my code, Out of the box java script function used to add Tree_scrollIntoView function to Ques of window.onload calls - _spBodyOnLoadFunctionNames(function_name) :
string jsScript = @"<script language=javascript>
function Tree_scrollIntoView()
{
var data = " + trvw.ClientID + @"_Data;
// var objDiv = document.getElementById(""trvw_scroll"");
if (!data)
{
return;
// if(objDiv!=null)
// {
//objDiv.scrollTop = objDiv.scrollHeight;
// };
}
if ((typeof(data.selectedClass) != ""undefined"") && (data.selectedClass != null))
{
var id = data.selectedNodeID.value;
if (id.length > 0)
{
var selectedNode = document.getElementById(id);
if ((typeof(selectedNode) != ""undefined"") && (selectedNode != null))
{
selectedNode.scrollIntoView(true)
}
}
}
// if(objDiv!=null)
// {
//objDiv.scrollLeft = 0;
// };
}
_spBodyOnLoadFunctionNames.push(""Tree_scrollIntoView"");
</script>";
string jsScriptKey="Scroll_treeview_to_selected";
if (!Page.ClientScript.IsStartupScriptRegistered(this.GetType(),jsScriptKey))
{
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), jsScriptKey, jsScript);
}