将选定的DDL值用作actionlink的参数

Take selected DDL value an use as parameter for actionlink

本文关键字:actionlink 参数 DDL      更新时间:2023-09-26

我有一个MVC视图,其中有几个下拉列表。那里有一些自定义验证,在某些条件下,会在下拉列表旁边显示一个操作链接。这些操作链接将弹出一个模式窗口,其中包含与下拉列表中所做选择相关的信息。

我的问题是,我似乎可以看到如何从下拉列表中选择值,并将其输入到我的ajax请求中!!

这是我的代码:(下拉)

        <div id="holderlist">
        @Html.DropDownListFor(i => i.holderid, (SelectList)ViewData["holdersList"], "", new { @class = "chosenlist" })   
    </div>

(动作链接)

 <div id="add" style="display:none;">
    @Html.ActionLink("Actions", "existingOfficers", "Roles",
        new { id = ?????<how do I get DDL chosen ID here>  },
        new { @class = "openDialog", dialog_id = "productDetail", dialog_title = "Workflow Centre" })
    </div>

(ajax请求)

<script type="text/javascript">
$.ajaxSetup({ cache: false });
$(document).ready(function () {
    $(".openDialog").live("click", function (e) {
        e.preventDefault();
        $("<div></div>")
  .addClass("dialog")
  .attr("id", $(this).attr("dialog-id"))
  .appendTo("body")
  .dialog({
      title: $(this).attr("dialog-title"),
      close: function () { $(this).remove() },
      modal: true,
       width: 706,                 
       height: 300
  })
  .load(this.href);
    });
    $(".close").live("click", function (e) {
        e.preventDefault();
        $(this).closest(".dialog").dialog("close");
    });
});

我不能做的是将ID设置为DDL中所选值的ID。DDL值目前没有存储在数据库中,因为这本质上是一个新的输入表单

如有任何帮助,我们将不胜感激:-)

jQuery(function($) {
$('.helpButton').each(function() {  
    $.data(this, 'dialog', 
      $(this).next('.helpDialog').dialog({
        autoOpen: false,  
        modal: true,  
        title: 'Info',  
        width: 600,  
        height: 400,  
        position: [200,0],  
        draggable: false  
      })
    );  
  }).click(function() {  
      $.data(this, 'dialog').dialog('open');  
      return false;  
  });  
});  ​

您可以在此处测试