最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Clear ViewBag message in MVC3 - Stack Overflow

programmeradmin10浏览0评论

I am having a registration form. After successful registration I have to set ViewBag.Msg in controller and displayed it on view. This time all the fields are clear and only "You have registered successfully" message is there.

Now if I click on Submit then jquery validations are called and error messages like "Required field" are displayed.

But "successful" message is still there. How can I clear this message?

I am having a registration form. After successful registration I have to set ViewBag.Msg in controller and displayed it on view. This time all the fields are clear and only "You have registered successfully" message is there.

Now if I click on Submit then jquery validations are called and error messages like "Required field" are displayed.

But "successful" message is still there. How can I clear this message?

Share Improve this question edited May 16, 2013 at 8:31 tereško 58.5k25 gold badges100 silver badges150 bronze badges asked May 16, 2013 at 4:29 user1120418user1120418 2713 gold badges8 silver badges18 bronze badges 1
  • Yep. We can't possibly answer this without your code. – gideon Commented May 16, 2013 at 5:01
Add a ment  | 

1 Answer 1

Reset to default 8

Use

TempData["mesage"]="Hello";

instead of

ViewBag.Message="Hello";

Because ViewBag maintain data on refresh also but TempData dispose after render once

发布评论

评论列表(0)

  1. 暂无评论