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

[Solved] Accessing control data in Razor

2 Answers 120 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jonathan
Top achievements
Rank 1
Jonathan asked on 11 Nov 2011, 04:36 PM
Right now, I'm trying to write a web page that has two major items: a TreeView and an Upload. The idea is that the TreeView represents a file structure on the hard drive (I got that working fine), and the Upload lets you upload files somewhere into that structure. The way I intend to let the user control where the uploaded files go is to somehow let the Upload know what node in the TreeView is currently selected.

What I'd like to do is pass the value of the currently selected node (which holds the full directory path that that node represents as a string) in as a route value in the Upload's Save() call. The only problem is that I don't know how to access the TreeView's nodes from within the definition of the route values. So basically, what would I put in place of the question marks in this snippet:

@(Html.Telerik().Upload()
    .Name("files")
    .Multiple(true)
    .Async(async => async
        .Save("Save", "File", new { @destinationDirectory = ???????})
        .Remove("Remove", "File")
        .AutoUpload(true)
    )
)

I know that in javascript I can just do

$('#fileViewer').data("tTreeView").getItemValue(e.item);

where "fileViewer" is the name of the TreeView. So I guess another way to look at the question is: what's the razor equivalent of that?

I'm working with all the latest stable versions of ASP.Net, MVC, and Telerik, and I'm working in C#.

2 Answers, 1 is accepted

Sort by
0
Accepted
Daniel
Telerik team
answered on 15 Nov 2011, 11:27 AM
Hi Jonathan,

There is no way to access TreeView's nodes from within the definition of the route values.
To pass the selected node you need to declare a handler for the OnUpload event and attach a data object, which contains the path, to the passed event. There is more detailed information on how to achieve this in the documentation


Kind regards,
Daniel
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
Jonathan
Top achievements
Rank 1
answered on 15 Nov 2011, 03:25 PM
Yeah, I had somebody else explain the difference between client and server side things to me. Thanks anyway!
Tags
General Discussions
Asked by
Jonathan
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Jonathan
Top achievements
Rank 1
Share this question
or