Javascript alert - Smart Navigation problem

  • Thread starter Marc Castrechini
  • Start date
M

Marc Castrechini

With SmartNavigation=true a call to display a simple javascript alert
returns in IE showing an "Invalid Pointer" error.

Apparently when SmartNavigation is disabled then the alert works correctly.

When I remove the <doctype> tag the alert works again.

I'd prefer to keep a doctype tag in my page if at all possible.

Doc type:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

Javascript function in code behind:
Public Sub ASPNET_MsgBox(ByVal Message As String)

System.Web.HttpContext.Current.Response.Write("<SCRIPT
LANGUAGE=""JavaScript"">" & vbCrLf)

System.Web.HttpContext.Current.Response.Write("alert(""" & Message & """)" &
vbCrLf)

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

End Sub


Does anyone know why this is?

- Castro
 
S

Steven Cheng[MSFT]

Hi Castro,

From your description, you found that when the asp.net's smart navigation
is turn on, if we use response.
write to write a clienscript block to client such as
<script language='javascript'>alert('message');</script>, it will failed
with "invalid pointer"

I've also tested on my side and did found this problem. I think this
problem is likely due to the Response.Write's output is conflicting with
the smartnavigation's output
script. The response.Write will always write out all the content before
the page's render out content. I recommend that you try using
"RegisterStartupScript " to register the client script, the
"RegisterStartupScript " will ensure that the script block is rendered
within the Page's body and in the proper location. You can retireve the
current Request 's Page handler via
HttpContext.Current.Handler
and call the page's RegisterStartupScript to write out the messagebox script

For example:
Public Sub ASPNET_MsgBox(ByVal Message As String)

Dim script As String = "<script
language='javascript'>alert('{0}');</script>"
Dim page As System.Web.UI.Page = HttpContext.Current.Handler

page.RegisterStartupScript("showmb", String.Format(script, Message))

End Sub

Please have a try to see whether this helps. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
 
S

Steven Cheng[MSFT]

Hi Castro,

Have you had a chance to check out the suggestions in my last reply or have
you got any further ideas on this issue? If you have anything unclear or if
there're anything else we can help, please feel free to post here. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
 

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

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top