RadTreeView for ASP.NET

Setting the focus on Telerik RadTreeView after postback Send comments on this topic.
Example scenarios (How to) > Server-side > Setting the focus on Telerik RadTreeView after postback

Glossary Item Box

To set the focus on the treeview after a postback has occurred, you should use the following approach:

Example:

ASPX Copy Code
...
<rad:radtreeview runat="Server" OnNodeClick="HandleClick" ... />
...
        
C# Copy Code
...
protected void HandleClick(object sender, RadTreeNodeEventArgs NodeEvent)
{
// do something related to the node clicked
...
// focus the treeview
System.Text.StringBuilder sb = new System.Text.StringBuilder("");
sb.Append(
" ");

if (!Page.IsStartupScriptRegistered("setFocus"))
{
 Page.RegisterStartupScript(
"setFocus", sb.ToString());
}
}
...
        
VB.NET Copy Code
...
Protected Sub HandleClick(ByVal sender As Object, ByVal NodeEvent As RadTreeNodeEventArgs)
    ' do something related to the node clicked
    ' focus the treeview
    Dim sb As System.Text.StringBuilder = New System.Text.StringBuilder("")
    sb.Append(" ")
    If Not Page.IsStartupScriptRegistered("setFocus") Then
        Page.RegisterStartupScript("setFocus", sb.ToString)
    End If
End Sub
...