读取控制的DropDownList从视图中查看视图、DropDownList

2023-09-06 15:18:56 作者:凉眸。こ萌面人

VS '12 asp.net C#MVC互联网应用+剑道UI,EF code首先,剑道UI

VS '12 asp.net C# mvc Internet App + Kendo UI , EF Code First, Kendo UI

使用剑道DDL

 @(Html.Kendo().DropDownList()
          .Name("dropdownlist")
          .BindTo(new string[] { "Leasehold A", "Mineral Owner", "Prospect", "StrangerInTitleNote", "StrangerInTitleNoteInfo", "StrangerLeasingNote", "StrangerLeasingNoteInfo", "Subject To", "Surface Note", "Surface Note Info", "Unreleased Mortage", "Unreleased Oil and Gas Leasors", "Vesting Note" })
          )

很简单吧? - 现在我想提取所选择的项目,并把它变成一个ActionLink的

Very simple right? - now i want to extract the selected Item and place it into an Actionlink

@Html.ActionLink("Create New", "Create", new { id =  } )', null) ....

做什么,我把在 ID = 点。我怎样才能得到这个工作。感谢您的任何答案。 PS:不熟悉MVC得多或任何HTML,到目前为止,我必须用一个脚本? - preferably我想不会离开视图。

what do I place at the id= spot. How can I get this to work. Thanks for any answers. PS: Not familiar with MVC to much or any HTML so far, must I use a Script? - preferably I would like to not leave the view.

推荐答案

我不喜欢这样。也许不是最好的,但它为我工作。

I do it like this. May not be the best but it works for me.

下面是链接:

@Html.ActionLink("Click Me", "YourAction", new { controller = "YourController"}, new       {id="YourActionLinkName"})

本。点击功能

The .click function

$('#YourActionLinkName').click(function (e) {


            var val = $("#dropdownlist").val();
            var href = "/YourApp/YourController/YourAction/" + val;
            this.href = ""; //clears out old href for reuse
            this.href = href; //changes href value to currently slected dropdown value

        });