In your answer, you mention you've used VB.Net
code to help with the execution of your Insert
code. You could further expand your usage of VB.Net
in the code behind to help with the problem you are faced with.
Here is an example which hopefully helps you:
In your ASPX
page, you could replace your form code with the following:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button runat="server" ID="btnInsertInto" Text="Insert" />
</div>
</form>
</body>
</html>
The submission of the form is now handled by the ASP Button
(asp:Button
) and is connected to an event in the code-behind file:
Private Sub btnInsertInto_Click(sender As Object, e As EventArgs) Handles btnInsertInto.Click
' Handle button click code here..
End Sub
Within the same code-behind class, you can make use of the Page_Load
sub to handle your page initialization code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
' Page initialization code goes here..
End If
End Sub
So, the entire code-behind class looks like:
Public Class WebForm1
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
' Page initialization code goes here..
End If
End Sub
Private Sub btnInsertInto_Click(sender As Object, e As EventArgs) Handles btnInsertInto.Click
' Handle button click code here..
End Sub
End Class
When I tested this before posting, I was able to refresh the page without the insert code being executed.