confirm message in asp.net using javascript

S

Stephen Witter

I am trying to place a very simple javascript alert in asp.net. I am
using web matrix. When I place the following code in the code view it
screws everything up:

Sub My_MsgBox()
System.Web.HttpContext.Current.Response.Write("<SCRIPT
LANGUAGE=""JavaScript"">" & vbCrLf)
System.Web.HttpContext.Current.Response.Write("alert(""" & "hi" &
""")" & vbCrLf)
System.Web.HttpContext.Current.Response.Write("</script>")
End Sub

The last script tag is being recognized by web matrix as a legit
script tag even though it is in a response.write statement. I have
noticed this happens when I have tried it using other prcedures
(unsuccessfully) such as a window.open call that use script tags.
What happens is the existing script tags in web matrix used to
separate the code from the html (web matrix doesn't use code behind)
get messed up because it sees the other script tag and proceeds to
hose up my code.

Any thoughts?
 
C

Chris R. Timmons

(e-mail address removed) (Stephen Witter) wrote in
I am trying to place a very simple javascript alert in asp.net.
I am using web matrix. When I place the following code in the
code view it screws everything up:

Sub My_MsgBox()
System.Web.HttpContext.Current.Response.Write("<SCRIPT
LANGUAGE=""JavaScript"">" & vbCrLf)
System.Web.HttpContext.Current.Response.Write("alert(""" &
"hi" &
""")" & vbCrLf)
System.Web.HttpContext.Current.Response.Write("</script>")
End Sub

The last script tag is being recognized by web matrix as a legit
script tag even though it is in a response.write statement. I
have noticed this happens when I have tried it using other
prcedures (unsuccessfully) such as a window.open call that use
script tags. What happens is the existing script tags in web
matrix used to separate the code from the html (web matrix
doesn't use code behind) get messed up because it sees the other
script tag and proceeds to hose up my code.

Any thoughts?


Try

System.Web.HttpContext.Current.Response.Write("</scr")
System.Web.HttpContext.Current.Response.Write("ipt>")

That should make WebMatrix happy. You may have to treat the opening
<script> tag the same way.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top