Asp.net MVC选定的索引更改/ Ajax.ActionLink [英] Asp.net MVC Selected Index Changed / Ajax.ActionLink

查看:139
本文介绍了Asp.net MVC选定的索引更改/ Ajax.ActionLink的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须使用剃刀语法Asp.Net MVC的页面。在页面我有一个DropDownList和DIV部分,我想替换取决于组合框的选定值使用Ajax.ActionLink功能DIV内容

I have a page in Asp.Net MVC using the Razor syntax. In the page I have a DropDownList, and a DIV section that I would like to replace the content in the DIV depending on the selected value of the combobox using the Ajax.ActionLink functionality

有没有办法做到这一点?

Is there a way to do this?

感谢

标记

推荐答案

我宁愿用一个形式大于一个链接,因为它更加适合于你想达到什么样的:

I would rather use a form than a link as it is more adapted to what you are trying to achieve:

@using (Ajax.BeginForm(
    "Change", 
    "Home", 
    new AjaxOptions { UpdateTargetId = "result" }
))
{
    @Html.FropDownListFor(x => x.Foo, Model.Foos, "-- Select a foo --")
    <input type="submit" value="Change" />
}

<div id="result"></div>

和相应的控制器动作:

public ActionResult Change(string foo)
{
    string view = ... // select the partial based on the selected value
    return PartialView(view);
}

这篇关于Asp.net MVC选定的索引更改/ Ajax.ActionLink的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆