停止ASP.NET回传显示作为单独的页面? [英] Stop ASP.NET PostBacks Showing As Separate Pages?

查看:192
本文介绍了停止ASP.NET回传显示作为单独的页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ASP.NET的形式,用户可以做出很多改变,每次他们做出改变的页面PostsBack和细节都进行更新。

I have an ASP.NET form that the user can make lots of changes to, each time they make a change the page PostsBack and the details are updated.

如果用户点击浏览器后退按钮他们回去通过页面的所有previous版本。

If the user hits the browser back button they go back through all the previous versions of the page.

是否有可能阻止每次回发由浏览器被视为一个新的页面?

Is it possible to stop each PostBack being treated by the browser as a new page?

所以,将使他们喜欢的任何变化,如果他们打后退按钮就他们带来的previous的形式和形式不一样,但不同的版本?

So the would make any changes they like and if they hit the back button it brings them to the previous form and not the same form but a different version?

我知道我可以使用AJAX来更新值,但我不是一个先进的codeR所以试图让事情变得简单,因为我没有使用AJAX之前。

I know I could use AJAX to update values but I'm not an advanced coder so trying to keep things simple as I haven't used AJAX before.

推荐答案

您可以使用一个技巧做到这一点。

You could use a trick to do it.

在回发时你可以设置一个会话位真说,他们提交的表单。在您的回发检查,看看是否值设置。如果他们试图再次做到这一点,你可以终止它。它不会prevent本身的回传,但你可以做任何控制逻辑和prevent它。

On postback you can set a session bit to true saying they submitted that form. On your postback check to see if that value is set. If it is they are trying to do it again and you can just abort it. It wouldn't prevent the postback per se but you could control the logic and prevent it from DOING anything.

我在jQuery提供了一些很好的方法来做到这一点,它会是一个学习的经验,但我想你问这会工作亲自将探索阿贾克斯。在每个会话的基础。如果你只想要1提交用不完一个数据库来存储活动。

I personally would explore ajax as Jquery provides some nice ways to do it and it'd be a learning experience but I suppose this would work as you are asking. On a per session basis. If you only want 1 submission ever use a database to store the activity.

这篇关于停止ASP.NET回传显示作为单独的页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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