如何停止在asp.net中重新插入值 [英] how to stop reinserting the values in asp.net

查看:83
本文介绍了如何停止在asp.net中重新插入值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了员工注册页面,其中包含姓名,年龄,名称,身份证等。当我提交表格时记录已成功插入。现在我的问题是,当刷新表单再次成功插入消息记录时,这些过程将一直持续到关闭表单或停止刷新页面为止。 使用以前的数据自动插入相同的记录。请给出如何解决它的建议。谢谢你的高级。

I have created Employee Registration page with Name, Age, Designation, Id etc. When I have submitting the form record is inserted successfully. Now my issue is when ever refreshing the form again I got the message record is inserted successfully, these process is continue until u close the form or stop refreshing the page. The same records are automatically inserted with previous data. Pls give suggestions how to solve it. Thanks in advanced.

推荐答案

这发生在页面刷新时,它会触发相同的按钮点击事件,从而导致重复插入。有很多方法可以做到这一点。

1.完成插入后重定向到同一页面。

This happens as on page refresh, it fires the same button click event and thus causing duplicate inserts. There are many ways to do this.
1. Redirect to the same page after insert is done.
Response.Redirect(Request.Url.AbsoluteUri);



2.在插入后放置RequiredFieldValidator并清除所有表单域。还有用于防止在db中重复数据插入的逻辑。

3. [推荐]

请按照这些链接使用session& viewstate。

避免重复记录使用ASP.NET刷新页面 [ ^ ]

避免在ASP.NET中的用户刷新页面时插入两次 [ ^ ]



希望,它有所帮助:)


2. Put RequiredFieldValidator and clear all the form fields after insert. Also put logic for preventing duplicate data insert in db.
3. [Recommended]
Please follow these links to do it using session & viewstate.
Avoid Duplicate record insert on page refresh using ASP.NET[^]
Avoid inserting twice when user refresh page in ASP.NET[^]

Hope, it helps :)


这是由于以下原因:



第一次提交注册而你得到了警报信息。但是,在您再次刷新页面后意味着它再次提交。请检查您的数据库,您将有多个记录。



请按照以下链接提交后如何停止刷新页面:

提交请求后停止刷新 [ ^ ]
It happens due to following reason:

First time you submit the registration and you got the alert message. But after you are refreshing the page again means it is submitting again. Please check your database you will have multiple records.

Please follow below link how to stop refresh page after submitting:
Stop Refresh after Submitting your Request[^]


这篇关于如何停止在asp.net中重新插入值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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