This is a migrated thread and some comments may be shown as answers.

NavigateUrl

2 Answers 35 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Sasan
Top achievements
Rank 1
Sasan asked on 04 Nov 2011, 12:03 AM
I've been trying to change the NavigateUrl attribute of a Node in a TreeView from codebehind when the tree is initially loaded.
Protected Sub RadTreeView1_NodeClick(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadTreeNodeEventArgs) Handles RadTreeView1.Load
    RadTreeView1.FindNodeByText("Upload Company Documents").NavigateUrl() = "~/upload/upload.aspx?b=" & Server.UrlEncode(Encrypt("&DT=C" & "&dummy="))
End Sub

This returns the following error: "Unable to cast object of type 'System.EventArgs' to type 'Telerik.Web.UI.RadTreeNodeEventArgs'."
In order to get around this problem I decided to do a Response.redirect and I can move to the desired page but I would like to be able to change the NavigateUrl attribute of a given Node during the Load of the TreeView.
Protected Sub RadTreeView1_NodeClick(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadTreeNodeEventArgs) Handles RadTreeView1.NodeClick
    If RadTreeView1.FindNodeByText("Upload Company Documents").Selected Then
        Response.Redirect("~/upload/upload.aspx?b=" & Server.UrlEncode(Encrypt("&DT=C" & "&dummy="))
    End If
End Sub

Any help is appreciated.

2 Answers, 1 is accepted

Sort by
0
Accepted
Kevin
Top achievements
Rank 2
answered on 04 Nov 2011, 01:15 PM
Hello Sasan,

The reason you get that error is because your method signature for the Load event is incorrect. It should look like this:

Protected Sub RadTreeView1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadTreeView1.Load
    RadTreeView1.FindNodeByText("Upload Company Documents").NavigateUrl = "~/upload/upload.aspx?b=" & Server.UrlEncode(Encrypt("&DT=C" & "&dummy="))
End Sub

That's what the error was saying, the e parameter needed to be of type System.EventArgs. The way you had is for the NodeClick event and some other RadTreeView events.

I hope that helps.
0
Sasan
Top achievements
Rank 1
answered on 04 Nov 2011, 04:49 PM
Thank you Kevin!
Tags
TreeView
Asked by
Sasan
Top achievements
Rank 1
Answers by
Kevin
Top achievements
Rank 2
Sasan
Top achievements
Rank 1
Share this question
or