C#中使用asp.net mvc的时候如何设置AutoPostBack属性? [英] C# How to set the autopostback property when using asp.net mvc?

查看:317
本文介绍了C#中使用asp.net mvc的时候如何设置AutoPostBack属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用asp.net MVC框架。在我的网页我有一个dropdwonbox和被点击的选项时,我要到另外一个页面。但我怎么也找不到/在哪里设置AutoPostBack属性为true。这是code我使用的:

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:

.aspx的:

<%= 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屋!

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