如何清除后回到asp.net mvc的后场? [英] How to clear fields after post back in asp.net mvc?

查看:125
本文介绍了如何清除后回到asp.net mvc的后场?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道我怎么在asp.net mvc的回传后场清楚?就像现在,当出现验证错误的字段留填充任何一个用户将输入。这是好的但是,如果没有发生检验错误,我希望所有来清除字段和要显示的消息。

I am wondering how do I clear fields after a postback in asp.net mvc? Like right now when validation errors occur the fields stay populated with whatever a user would entered. This is fine however, when no validation errors occur I want the all the fields to clear and a message to display.

所以,现在我有成功的显示使用的ViewData,但不知道怎么去田里清除。

So right now I have the success displaying by using ViewData but not sure how to get the fields to clear.

推荐答案

听起来像是一个工作的的 PRG(后重定向获取)模式的,因为你不希望用户刷新页面,并再次提交。

Sounds like a job for the PRG (Post Redirect Get) pattern because you don't want the users to refresh the page and have it submit again.

要做到这一点,我会把消息或标志的TempData的,这样你可以检查,当你重定向回原来的网址,然后显示一个信息给用户。

To do this I would put a message or flag in your TempData so that you can inspect that when you redirect back to the original url to then display a message to the user.

这篇关于如何清除后回到asp.net mvc的后场?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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