Resolved Redirect after SQL insert


New member
Aug 18, 2022
Programming Experience
I hope someone can help! I am a newbie/code monkey who can get by with a few things but this one has me pulling my hair out how simple I assume it is. I have a form on an aspx file which when the user fills it in and clicks the insert button, it adds the data to the sql using a stored procedure. This all works fine.

However at the moment it then just refreshes the page to a blank form, what I would like to happen is simply redirect to an external HTTPS site.

I tried the PostBackUrl on the button, but then it skips the actual data insertion. I have tried adding a subby on the codebehind VB file, but it does the same thing, skipping the insert, so obviously i need to run the sub later, but dont know what to put in to trigger it. Any help would be much appreciated. There is a master page to handle the css, content tags and footer which I guess has no relevance to assist here, unless I'm wrong. The two files are as follows (main form simplified to reduce the amount to read):


<%@ Page Title="" Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="otherfile.aspx.vb" Inherits="otherfile"%>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<title>blah blah</title>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

<asp:FormView ID="FormView1" runat="server" DataKeyNames="datakeyname"
DataSourceID="SqlDataSource1" DefaultMode="Insert" style="width:100%">

<form action="">

<h3>Account Details</h3>
<div class="account-details">
<div><label>afield</label><asp:TextBox name="afield" ID="afield" runat="server"
Text='<%# Bind("afield") %>'/></div>
<div style="justify-content: center;">
ErrorMessage="This cannot be left blank"
forecolor="Red" >


<div style="text-align:center;">
<asp:Button Class="buttoninsert" ID="InsertButton" runat="server" CausesValidation="True"
CommandName="insert" Text="Create Account" OnClick="finished_click" />/></div>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ mystring %>"


<asp:parameter Name="afield" Type="String" />




My code behind file

Partial Class otherfile
Inherits System.Web.UI.Page

Private Sub finished_Click(sender As Object, e As EventArgs)
End Sub

End Class
Top Bottom