Solved

RESPONSE REDIRECT ISSUE ON SUBMIT

Posted on 2011-02-14
3
559 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

830 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