Redirecting to a page after clicking OK in confirmation box in asp.net VB
I have an if condition on a button which redirects to another page. I want a confirmation box to pop up if the condition is true. If the user clicks ok on the box he should be redirecting to the page else not. I am not that good with Java script. I just tried to develop something on the following lines but nothing seems to work. Any help in this regard would be much appreciated. I am working in Asp.net on the client side and VB
Dim sb As New System.Text.StringBuilder()
sb.Append("<script type = 'text/javascript'>")
sb.Append("window.onload=function(){")
sb.Append("if (confirm('")
sb.Append(message)
sb.Append("'))};")
sb.Append(Response.redirect)
sb.Append("</script>")
ClientScript.RegisterClientScriptBlock(Me.GetType(), "confirm", sb.ToString())
Replace:
sb.Append("'))};")
sb.Append(Response.redirect)
sb.Append("</script>")
With:
sb.Append("')){")
sb.Append("window.location = 'http://domain/page.aspx';")
sb.Append("}};</script>")
链接地址: http://www.djcxy.com/p/71538.html