Ver Mensaje Individual
  #3 (permalink)  
Antiguo 21/09/2010, 07:03
chuchufuentes
 
Fecha de Ingreso: mayo-2008
Mensajes: 353
Antigüedad: 16 años
Puntos: 3
De acuerdo Respuesta: Evitar Insert cuando hacen refresh F5

A mi me sucedió lo mismo al usuario no le puedes amarrar las manos.
aquí lo que hice

Imports System.Web.SessionState

Private IsPageRefresh As [Boolean] = False

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
Dim SourceTextBox As TextBox
SourceTextBox = CType(PreviousPage.FindControl("txtuser"), _
TextBox)
If Not SourceTextBox Is Nothing Then

Session("update") = Server.UrlEncode(System.DateTime.Now.ToString())


' esto es para controlar el F5
ViewState("postids") = System.Guid.NewGuid().ToString()
Session("postid") = ViewState("postids").ToString()

Else
If ViewState("postids").ToString() <> Session("postid").ToString() Then
IsPageRefresh = True
End If
Session("postid") = System.Guid.NewGuid().ToString()
ViewState("postids") = Session("postid")

End If
End If
End Sub


luego donde tienes proceso para actualizar va esto

If Not IsPageRefresh Then
If ddlpais.SelectedItem.Value = "Select" Or ddlregion.SelectedItem.Value = "Select" Or ddlclte.SelectedItem.Value = "Select" Or txtnrosini.Text = "" Then
alert("Pais o Region o Cliente o Nro. Siniestro NO correctos")
Exit Sub
End If

If txtcosto.Text <> "" Then
txtcosto.Text = Replace(txtcosto.Text, ",", ".")
Else
txtcosto.Text = "0"
End If

If txtventa.Text <> "" Then
txtventa.Text = Replace(txtventa.Text, ",", ".")
Else
txtventa.Text = "0"
End If

If txtflete.Text <> "" Then
txtflete.Text = Replace(txtflete.Text, ",", ".")
Else
txtflete.Text = "0"
End If

If txtcant.Text = "" Then
txtcant.Text = "0"
End If

txtpart.Text = ""
txtdescrparte.Text = ""
txtcosto.Text = ""
txtflete.Text = ""
txtventa.Text = ""
txtcant.Text = ""
FillCustomerInGrid()
Else
'esto es por que cuando le dan F5 no borra los datos y hay que borrarlo de nuevo
txtpart.Text = ""
txtdescrparte.Text = ""
txtcosto.Text = ""
txtflete.Text = ""
txtventa.Text = ""
txtcant.Text = ""
FillCustomerInGrid()
End If

suerte