Solved

RESPONSE REDIRECT ISSUE ON SUBMIT

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now