开发者

Show error message using popup in a mvc project

I want to create an error handler for a mvc project, but the error message should be displayed in a popup. I tried to override onException event of the controller, but I don't know how to get back to the initial page and s开发者_高级运维how the popup. I don't want to be redirected to an error page. Any advices?


The only way to do this is to do an AJAX form submission. If the save fails, show a popup. If the save succeeds redirect the user to a new page. That's the only way to keep the user on the page. (Well the only non-clunky way.)

As mentioned in the top-level comment by zvolkov, this is very desktop-y. There shouldn't be a 100% correlation to how a desktop program works vs. how a web program works. While there are parallels, it's OK to deviate.

The hardcore standards folks will tell you to not rely 100% on an AJAX submit, since it isn't 100% browser compatible and can break on some smartphones, depending on what you're doing. You form should be able to gracefully fall back to a standard HTTP-POST action.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜