1

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

Using Kendo 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" })
          )

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) ....

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.

Mike Perrenoud
  • 66,820
  • 29
  • 157
  • 232
Pakk
  • 1,299
  • 2
  • 18
  • 36
  • 1
    This will be impossible server-side; you don't have a selected item server-side. This value changes as the user makes changes. – Mike Perrenoud Sep 09 '13 at 20:00
  • So ill have to have them click on a Submit, to a specific controller that does w/e i need it to do and return the view? – Pakk Sep 09 '13 at 20:05
  • Yes, but you were navigating away anyway, to another view, right? This appears to be a view to **create** new records, which was likely a different interface yes? – Mike Perrenoud Sep 09 '13 at 20:06
  • well kinda, its a ddl to an edit view so on click send me to this page but keep current one open cause it has images showing – Pakk Sep 09 '13 at 21:03

1 Answers1

2

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

Here is the link:

@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

        });
Alan Fisher
  • 2,005
  • 4
  • 41
  • 61
  • Very nice!! I am assuming not the best cause it captures every click? either way it works perfectly for me, thank you so much you saved me a CRAP TON OF PAIN +1 – Pakk Sep 10 '13 at 12:45