C#,C++, Java,php,vb.net find oops-solution,OOPs FAQs : Object Oriented Interview Questions and programming solution.sql server2000,2005,2008, issue related to SSRS,Jquery,javascript and postgreSQL.Articles on WEB services,WCF and windows services.
Search This Blog
Wednesday, August 10, 2011
Rapid solution in Programming and Related Bug: How to use Merge T-SQL Command
Rapid solution in Programming and Related Bug: How to use Merge T-SQL Command: "The MERGE statement performs INSERT/UPDATE/DELETE operations on a target table based on the results of a join with a source table. In the s..."
Sunday, August 7, 2011
Preventing Re-submission of data on Browser Refresh
Avoid Duplicate record insert on page refresh using ASP.NET
Code
VB.net
Dim IsPageRefresh As Boolean = False
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Page.IsPostBack Then
If ViewState("postid").ToString() = Session("postid").ToString() Then
IsPageRefresh = True
End If
Session("postid") = System.Guid.NewGuid().ToString()
ViewState("postid") = Session("postid")
Code
VB.net
Dim IsPageRefresh As Boolean = False
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Page.IsPostBack Then
If ViewState("postid").ToString() = Session("postid").ToString() Then
IsPageRefresh = True
End If
Session("postid") = System.Guid.NewGuid().ToString()
ViewState("postid") = Session("postid")
End Sub
Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
If Page.IsValid And IsPageRefresh Then
' Write your Code here
End Sub
C#
bool IsPageRefresh = false;
protected void Page_Load(object sender, System.EventArgs e)
{
if (Page.IsPostBack) {
if (ViewState("postid").ToString() == Session("postid").ToString()) {
IsPageRefresh = true;
}
}
Session("postid") = System.Guid.NewGuid().ToString();
ViewState("postid") = Session("postid");
}
protected void btnSubmit_Click(object sender, System.EventArgs e)
{
if (Page.IsValid & IsPageRefresh) {
// Write your Code here
}
}
Subscribe to:
Posts
(
Atom
)