C# 如何在使用 asp.net mvc 时设置 autopostback 属性? [英] C# How to set the autopostback property when using asp.net mvc?
本文介绍了C# 如何在使用 asp.net mvc 时设置 autopostback 属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 asp.net MVC 框架.在我的页面上,我有一个 dropdwonbox,当单击一个选项时,我想转到另一个页面.但我找不到如何/在哪里将 autopostback 属性设置为 true.这是我正在使用的代码:
I am using asp.net MVC framework. On my page i have a dropdwonbox and when an option is clicked i want to go to another page. But i can't find how/where to set the autopostback property to true. This is the code i'm using:
ASP:
<%= Html.DropDownList("qchap", new SelectList( (IEnumerable)ViewData["qchap"], "Id", "Title" )) %>
控制器:
public ActionResult Index(int id)
{
Chapter c = new Chapter();
ViewData["qchap"] = c.GetAllChaptersByManual(id);
return View();
}
我需要做什么才能使用自动回发功能?
What do i have to do to use the autopostback functionality?
推荐答案
您可以使用 onchange 客户端事件:
You can use the onchange client event:
<%= Html.DropDownList("qchap",
new SelectList( (IEnumerable)ViewData["qchap"], "Id", "Title" ),
new { onchange = "this.form.submit();" }) %>
这篇关于C# 如何在使用 asp.net mvc 时设置 autopostback 属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文