使用剃刀(.net 4.0)发回dropdowlist [英] post back dropdowlist using razor (.net 4.0)

查看:135
本文介绍了使用剃刀(.net 4.0)发回dropdowlist的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<td> @Html.DropDownList("ddl")




如何为此下拉列表发回




how to make post back for this dropdownlist

推荐答案

如果我正确理解了这些问题,则需要使用ajax来执行此操作.在MVC中,控件没有像在Web窗体中那样具有回发方法.您将需要使用javascript进行连接.

这是一个如何使它工作的示例.

If I understand the questions correctly you will need to use ajax to do this. In MVC controls don''t have a postback method like they do in web forms. You will need to hook it up with javascript.

Here is an example of how to get that working.

<script type="text/javascript">


(" ).change(功能(e){ // 用于更新页面或执行选择更改时您需要做的事情的代码. }); </script>
("#ddl").change(function(e) { // Code to update the page or do what ever you need to do when the select changes. }); </script>


这篇关于使用剃刀(.net 4.0)发回dropdowlist的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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