Response.Write Problem

C

crjunk

I'm usiing the following code to create an alert message box when
certain conditions occur with the user's input date.

Public Sub ASPNET_MsgBox(ByVal MyMessage As String)
System.Web.HttpContext.Current.Response.Write("<SCRIPT
LANGUAGE=""JavaScript"">" & vbCrLf)
System.Web.HttpContext.Current.Response.Write("alert('" &
MyMessage & "')" & vbCrLf)
System.Web.HttpContext.Current.Response.Write("</SCRIPT>")
End

When I test the ASPX with a browser and review the html code that is
rendered, I see where the JavaScript is being written before the the
<html> tag.

This is what I am talking about:

<SCRIPT LANGUAGE="JavaScript">
alert(Hello World!')
</SCRIPT>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html>
<head>

What do I need to do so that the script is written within the <body>
tags?

Thanks,
C.R. Junk
 
G

Guest

I'm usiing the following code to create an alert message box when
certain conditions occur with the user's input date.

Public Sub ASPNET_MsgBox(ByVal MyMessage As String)
        System.Web.HttpContext.Current.Response.Write("<SCRIPT
LANGUAGE=""JavaScript"">" & vbCrLf)
        System.Web.HttpContext.Current.Response.Write("alert('" &
MyMessage & "')" & vbCrLf)
        System.Web.HttpContext.Current.Response.Write("</SCRIPT>")
End

When I test the ASPX with a browser and review the html code that is
rendered, I see where the JavaScript is being written before the the
<html> tag.

This is what I am talking about:

<SCRIPT LANGUAGE="JavaScript">
alert(Hello World!')
</SCRIPT>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
        "http://www.w3.org/TR/html4/strict.dtd">

<html>
    <head>

What do I need to do so that the script is written within the <body>
tags?

Thanks,
C.R. Junk

The last post on the following link could help
http://www.velocityreviews.com/forums/t94207-responsewrite.html
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top