您的位置:首页 > 编程语言 > ASP

ASP.NET中F5刷新按键数据插入两次的问题

2005-07-14 18:58 351 查看
利用服务器控件做的页面,刷新按钮一按,客户端会把View中的数据重新送到服务器端,从而造成数据插入两次的问题。

解决方案利用服务器端的session和客户端的ViewState中保存的数据是否不同来判定。

</script>
<html>
<head>
<title>Preventing Duplicate Record Insertion on Page Refresh - Using a Session and ViewState Variables</title>
</head>
<body>
<form runat="server">
<p>First Name <asp:TextBox id="firstName" runat="server" />
<p>Last Name <asp:TextBox id="lastName" runat="server" />
<p><asp:Button id="Button1" onclick="Button1_Click" runat="server" Text="Add Employee" />
<p><asp:Label id="Message" runat="server" />
<input id="hiddenSession" type="hidden" runat="server" />
</form>
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: