【发布时间】:2011-03-05 11:16:26
【问题描述】:
Protected Sub ImageButton3_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageButton3.Click
If ImageButton3.ImageUrl = ("./images/back.png") Then
Me.Response.Redirect("http://www.volvobusesindia.com")
Else
Try
Dim SmtpServer As New SmtpClient()
Dim mail As New MailMessage()
SmtpServer.Credentials = New Net.NetworkCredential("info@volvobusesindia.com", "xxxxxx")
SmtpServer.Port = 25
SmtpServer.Host = "mail.volvobusesindia.com"
mail = New MailMessage()
mail.From = New MailAddress("info@volvobusesindia.com")
mail.To.Add(Literal23.Text)
mail.Subject = "VolvoBusesIndia:E-Ticket Confirmation"
mail.Body = "<B>" + "||| -- VOLVOBUSESINDIA : E-Ticket Confirmation -- |||" + "</B>" + "<BR><BR><BR>" + "<B>" + "PNR Number : " + "</B>" & " " & Literal2.Text + "<BR><BR>" + "<B>" + "Payment Reference Number : " + "</B>" & " " & Literal1.Text + "<BR><BR>" + "<B>" + "Ticket Number : " + "</B>" & " " & Literal3.Text + "<BR><BR>" + "<B>" + "Travels : " + "</B>" & " " & Literal4.Text + "<BR><BR>" + "<B>" + "From : " + "</B>" & " " & Literal7.Text + "<BR><BR>" + "<B>" + "To : " + "</B>" & " " & Literal8.Text + "<BR><BR>" + "<B>" + "Journey Date : " + "</B>" & " " & Literal10.Text + "<BR><BR>" + "<B>" + "Departure : " + "</B>" & " " & Literal11.Text + "<BR><BR>" + "<B>" + "Arrival : " + "</B>" & " " & Literal12.Text + "<BR><BR>" + "<B>" + "Boarding Point : " + "</B>" & " " & Literal13.Text + "<BR><BR>" + "<B>" + "Dropping Point : " + "</B>" & " " & Literal14.Text + "<BR><BR>" + "<B>" + "Seat Selected : " + "</B>" & " " & Literal15.Text + "<BR><BR>" + "<B>" + "Seat Opted : " + "</B>" & " " & Literal16.Text + "<BR><BR>" + "<B>" + "Bus Type : " + "</B>" & " " & Literal17.Text + "<BR><BR>" + "<B>" + "Total Amount : " + "</B>" & " " & Literal19.Text + "<BR><BR>" + "<B>" + "Payment Status : " + "</B>" & " " & Label1.Text + "<BR><BR>" + "<B>" + "Paid via : " + "</B>" & " " & Literal20.Text + "<BR><BR>" + "<B>" + "Message : " + "</B>" & " " + "<BR>" & "Volvo Buses India Wishes you a very Happy Journey, hope you satisfied with our services"
mail.IsBodyHtml = True
SmtpServer.Send(mail)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
Try
Using conn = New SqlConnection(constr)
Using cmd = conn.CreateCommand()
conn.Open()
Dim sql As String = "UPDATE a1_ticket SET BANK = @bank, PAID = @paid, BID = @bid WHERE Ticket_no = @ticketNo"
cmd.CommandText = sql
cmd.Parameters.AddWithValue("@bank", Literal20.Text)
cmd.Parameters.AddWithValue("@paid", Label1.Text)
cmd.Parameters.AddWithValue("@bid", Literal21.Text)
cmd.Parameters.AddWithValue("@ticketNo", Literal3.Text)
cmd.ExecuteNonQuery()
End Using
End Using
Catch ex As Exception
Response.Write(ex.Message)
End Try
Response.Redirect("~/eticket.aspx?Pno=" & Literal2.Text & "&tid=" & Literal22.Text & "&Status=" & "Print_ticket_success")
End If
End Sub
出现页面未找到错误......但页面已经上传......
eticket.aspx 和网站http://www.volvobusesindia.com
【问题讨论】:
-
在没有更多上下文的情况下飞溅一段代码并不是提出问题的好方法。请说明代码的用途、预期结果和实际结果。
-
@user594849 你能给我们更多信息吗??它是一个编译问题?,数据访问问题?,数据可视化问题?,SQL 语法??
-
听起来他在使用页面时收到了 404。只需一点一点地调试它 - 删除 SMTP 和 DB 更新的整个 try 块,看看它是否有效。如果不是,它可能是重定向的路径引用之一。如果它确实有效,只需让代码重新进入。不过,我的钱在最后重定向到“~/eticket.aspx”。
-
我对切换条件视而不见,具体取决于当时按钮中的图像,以及直接放置在事件处理程序中的 SMTP 和 DB 更新代码!
-
检查您的 web.config 文件。是否有任何错误页面设置?如果是,请检查该文件是否存在。
标签: asp.net visual-studio-2008 sql-server-2005