Asp.net mvc 2 使用ASP.NETMVC2,Html.DropDownListFor-如何调用select上的JQuery函数?

Asp.net mvc 2 使用ASP.NETMVC2,Html.DropDownListFor-如何调用select上的JQuery函数?,asp.net-mvc-2,jquery,drop-down-menu,Asp.net Mvc 2,Jquery,Drop Down Menu,在我的视图中,我正在使用DropDownListFor: <%: Html.DropDownListFor(model => model.Type, new SelectList(ComponentsFactory.GetTypeList().Select(a => new { Name = Regex.Replace(a, @"^.*\.", ""), Value = a }).OrderBy(a => a.Name),

在我的视图中,我正在使用DropDownListFor:

<%: Html.DropDownListFor(model => model.Type, 
                        new SelectList(ComponentsFactory.GetTypeList().Select(a => new { Name = Regex.Replace(a, @"^.*\.", ""), Value = a }).OrderBy(a => a.Name),
                            "Value", "Name", Model.Type), "Select . . .", null) %> 
我想调用参数为“type”的“GetRequiredFields”作为select上所选项目的值,并使用它更新名为“RequiredFields”的“div”。我该怎么做?我是否需要使用Html.DropDownList for以外的其他内容?

试试这个

$(function(){
   $('#Type').change(function(){GetRequiredFields( $(this).val() );});
});
<%: Html.DropDownListFor(model => model.Type, 
                    new SelectList(ComponentsFactory.GetTypeList().Select(a => new { Name = Regex.Replace(a, @"^.*\.", ""), Value = a }).OrderBy(a => a.Name),
                        "Value", "Name", Model.Type), "Select . . .", new { @onchange = "GetRequiredFields(this);" }) %> 
试试这个

<%: Html.DropDownListFor(model => model.Type, 
                    new SelectList(ComponentsFactory.GetTypeList().Select(a => new { Name = Regex.Replace(a, @"^.*\.", ""), Value = a }).OrderBy(a => a.Name),
                        "Value", "Name", Model.Type), "Select . . .", new { @onchange = "GetRequiredFields(this);" }) %> 
function GetRequiredFields(type) 
{
    var selectedValue = $(type).val();
    ...//do JQuery AJAX stuff
}