471,052 Members | 1,205 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,052 software developers and data experts.

Javascript alert - Smart Navigation problem

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("<SC RIPT
LANGUAGE=""JavaScript"">" & vbCrLf)

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

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

End Sub
Does anyone know why this is?

- Castro
Nov 18 '05 #1
3 2419
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

Nov 18 '05 #2
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

Nov 18 '05 #3
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

Nov 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Gowhera Hussain | last post: by
4 posts views Thread by PiedmontBiz | last post: by
1 post views Thread by Priya | last post: by
1 post views Thread by Ying Huang-Isella | last post: by
2 posts views Thread by Marc Castrechini | last post: by
3 posts views Thread by Lee Forst | last post: by
8 posts views Thread by Frank | last post: by
54 posts views Thread by Boris | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.