在MVC中刷新页面 [英] Page refresh in MVC

查看:137
本文介绍了在MVC中刷新页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究Microsoft ASP MVC框架。这是我遇到的一个问题:
我有一个带有DropDownList的视图,该视图包含一个国家列表和一个用于状态的另一个DropDownList。 OnChange事件将表单发回,然后控制器将数据发送到应该更新的状态下拉列表。但是第二个DropDownList不变。它们保持刷新之前的状态。我应该怎么做才能解决此问题。

I'm studing Microsoft ASP MVC framework. Here is a problem I encounterd: I have a view with DropDownList containning a list of countries and another DropDownList for states. The OnChange event post the form back and then the controller sends data to the states drop down which should update. But the second DropDownList doesn't change. They stay as what it was before the refresh. What should I do to fix this.

预先感谢!

编辑:调用ModelState.Clear()在第二个控制器中修复该问题。感谢所有提供建议的人!真的非常感谢!

Call ModelState.Clear() in the second controller fix that problem. Thanks for all of you who offers suggestions! Really Thanks!

推荐答案

ASP.Net MVC提供了用于生成动态网页的新机制。与ASP.Net相比,它的抽象级别要低得多,因此故意不支持ASP.Net的类似事件的熟悉功能。

ASP.Net MVC provides a new mechanism for generating dynamic web pages. It is at a much lower level of abstraction than ASP.Net and as a result familiar features of ASP.Net like events are deliberately not supported.

尝试阅读此博客条目中的示例使用JQuery在客户端上执行所需的操作。这非常适合MVC方法

Try reading this blog entry for an example of how to do what you want on the client side using JQuery. This fits nicely into the MVC approach

这篇关于在MVC中刷新页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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