admin管理员组文章数量:1391987
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()
mand = New SqlCommand("Insert Into FireTest([Date],[Type],[Comments],[Completed By],[Trans Type]) Values(@Date,@Type,@Comments,@CompletedBy, @TransType)", connection)
mand.Parameters.AddWithValue("@Date", ThisDay)
mand.Parameters.AddWithValue("@Type", dropdownList1.SelectedValue)
mand.Parameters.AddWithValue("@Comments", TextBox1.Text)
mand.Parameters.AddWithValue("@CompletedBy", ThisUser)
mand.Parameters.AddWithValue("@TransType", transType)
mand.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?
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()
mand = New SqlCommand("Insert Into FireTest([Date],[Type],[Comments],[Completed By],[Trans Type]) Values(@Date,@Type,@Comments,@CompletedBy, @TransType)", connection)
mand.Parameters.AddWithValue("@Date", ThisDay)
mand.Parameters.AddWithValue("@Type", dropdownList1.SelectedValue)
mand.Parameters.AddWithValue("@Comments", TextBox1.Text)
mand.Parameters.AddWithValue("@CompletedBy", ThisUser)
mand.Parameters.AddWithValue("@TransType", transType)
mand.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?
Share Improve this question edited Jun 23, 2020 at 11:14 Andrew Morton 25.1k9 gold badges65 silver badges93 bronze badges asked Mar 7, 2014 at 9:00 KallumasaurusKallumasaurus 2711 gold badge4 silver badges15 bronze badges1 Answer
Reset to default 3You need to understand the difference between server-side code (what you have provided in your question, and is processed on the server) and client-side code (which is what the browser receives from the server and processes on the users machine).
The javascript alert
(or window.alert
) is a way of putting up a message box with an OK button. If you want a "yes/no" type response, you can use a confirm
(or window.confirm
) which will return true
if OK is selected and false
if Cancel is selected (or Escape pressed).
One of the fastest ways of getting what you want it to register script...
Try
...
Catch ex As Exception
Dim myScript as String = "window.alert('There is a problem');"
ClientScript.RegisterStartupScript(Me.GetType(), "myScript", myScript, True)
End Try
For more information on this function, see the MSDN entry
本文标签: aspnetUsing a Javascript alert in VBNetStack Overflow
版权声明:本文标题:asp.net - Using a Javascript alert in VB.Net - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744602355a2615143.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论