Solved

RESPONSE REDIRECT ISSUE ON SUBMIT

Posted on 2011-02-14
3
558 Views
Last Modified: 2012-05-11
I have attached the VB "Behind Code" for a form that when submitted sends data to the data base and
a subsequent e-mail.

Everything works as desired except the "Response Redirect".   It redirect to an unknow page but the e-mail and data
is sent.   Need help working out the "Response Redirect" problem.
Imports System.Net
Imports System.Net.Mail

Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs)

        Dim con As New System.Data.OleDb.OleDbConnection

        Dim myPath As String 
        myPath = Server.MapPath("database2.mdb")

        con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data source=" & myPath & ";"
        Dim myCommand As New System.Data.OleDb.OleDbCommand

        myCommand.CommandText = String.Format("INSERT INTO AOS([Dates],[Ship],[ArrTime],[InFlt],[History],[ETRDate],[ETRTime],[Station],[Reason1],[Status1],[Updated],[Reason2],[Parts]) VALUES('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}')", DateTime.Parse(Dates.Text), Ship.Text, ArrTime.Text, InFlt.Text, History.Text, DateTime.Parse(ETRDate.Text), ETRTime.Text, Station.Text, Reason1.Text, Status1.Text, Updated.Text, Reason2.Text, Parts.Text)
        myCommand.Connection = con
        con.Open()
        myCommand.ExecuteNonQuery()
        con.Close()

        'Send Email
        Dim smtpClient As SmtpClient = New SmtpClient()
        Dim message As MailMessage = New MailMessage()
        Dim fromAddress As MailAddress = New MailAddress("AOS_Report@laxpm.com") 
        message.From = fromAddress
        message.To.Add("mark@laxpm.com")
        message.Bcc.Add("mark@laxpm.com")
        message.Subject = "AOS EVENT"

        Dim palinBody As String = "Ship: " & Ship.Text & ""



        Dim plainView As AlternateView = AlternateView.CreateAlternateViewFromString(palinBody, Nothing, "text/plain")
        Dim htmlBody As String = "<p>Ship: " & Ship.Text & ""




        Dim htmlView As AlternateView = AlternateView.CreateAlternateViewFromString(htmlBody, Nothing, "text/html")
        message.AlternateViews.Add(plainView)
        message.AlternateViews.Add(htmlView)
        message.Priority = MailPriority.High
        smtpClient.Host = "mail.laxpm.com"
        smtpClient.Send(message)

        Response.Redirect("http://las.laxpm.com/index.aspx")

    End Sub
 
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

End Class

Open in new window

0
Comment
Question by:BOEING39
3 Comments
 
LVL 10

Accepted Solution

by:
himanshut earned 250 total points
ID: 34894030
to which page does it redirect?
Other than http://las.laxpm.com/index.aspx
0
 
LVL 39

Assisted Solution

by:Pratima Pharande
Pratima Pharande earned 250 total points
ID: 34894061

Is this is different site or your own site form where you are calling this

then try
Response.Redirect("index.aspx")

else try

Server.Transfer("http://las.laxpm.com/index.aspx")
0
 

Author Closing Comment

by:BOEING39
ID: 34894121
Guys thx for the help.   I used the Server Redirect with a different address which worked....
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question