Javascript alert - Smart Navigation problem

Discussion in 'ASP .Net' started by Marc Castrechini, Apr 9, 2004.

  1. 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
    Marc Castrechini, Apr 9, 2004
    #1
    1. Advertising

  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
    Steven Cheng[MSFT], Apr 10, 2004
    #2
    1. Advertising

  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
    Steven Cheng[MSFT], Apr 14, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Simone

    Smart Navigation Problem

    Simone, Jun 30, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    400
  2. Jason Rodman
    Replies:
    0
    Views:
    404
    Jason Rodman
    Jul 23, 2003
  3. Priya
    Replies:
    1
    Views:
    1,181
    Joe Gass
    Dec 2, 2003
  4. Ying Huang-Isella

    Smart Navigation problem with Javascript

    Ying Huang-Isella, Feb 19, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    715
    Peter Blum
    Feb 21, 2004
  5. Raghuram

    Problem with the Smart Navigation

    Raghuram, Jun 15, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    479
    =?Utf-8?B?U2hhaWxlc2g=?=
    Jul 13, 2005
Loading...

Share This Page