Basically I am looking to create a JavaScript alert in my code because I am displaying this web application in a mobile browser (off a tablet) and well the normal...
Try
' ...
Catch ex As Exception
Messagebox.Show("Insert Text Here")
End Try
doesn't work in a mobile browser, so I've been told to use a JavaScript alert but I have no idea where to start on this, yes I have used a little JS in the past and still trying to learn it but never came across using an alert. So here is my code below, in which I need to place this alert.
Protected Sub OkBtn_Click(sender As Object, e As System.EventArgs) Handles OkBtn.Click
Dim ThisDay As Date = Date.Today
Dim ThisUser As String
ThisUser = Request.QueryString("")
If ThisUser = "" Then
ThisUser = "Chris Heywood"
End If
Dim transType As String
transType = Request.QueryString("")
If transType = "" Then
transType = "Fire"
End If
connection.Open()
command = New SqlCommand("Insert Into FireTest([Date],[Type],[Comments],[Completed By],[Trans Type]) Values(@Date,@Type,@Comments,@CompletedBy, @TransType)", connection)
command.Parameters.AddWithValue("@Date", ThisDay)
command.Parameters.AddWithValue("@Type", dropdownList1.SelectedValue)
command.Parameters.AddWithValue("@Comments", TextBox1.Text)
command.Parameters.AddWithValue("@CompletedBy", ThisUser)
command.Parameters.AddWithValue("@TransType", transType)
command.ExecuteNonQuery()
connection.Close()
Response.Redirect("~/Production/Navigator.aspx")
End Sub
So basically this alert should be active if there is a error in inserting the information into the database (if there is nothing in the field).
P.S. Would jQuery be viable for this, as it's easy to type, rather than JS?