Response.Write Problem

  • Thread starter Thread starter crjunk
  • Start date Start date
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
 
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
 
Back
Top