Results 1 to 7 of 7

Thread: Little JavaScript/Smart Navigation help needed.

  1. #1

    Thread Starter
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464

    Little JavaScript/Smart Navigation help needed.

    I have a page that the user wants to see a success, failure message on a save. I do the save routine to the database, and set the blnReturn to whether it works or not. I was using the code below to write out the alert and it was working beautifully....until I turned smart navigation on for the project. Now I get script errors on the page. When I turn off smart navigation, it works again. The requirements are to use smart navigation, and use a alert to tell the user the status of the save. I am not fully up to speed on the javascript scene, so I could use some help in understanding this problem, and a good work around/ better solution.

    VB Code:
    1. If blnReturn Then
    2.             'Show a saved message.
    3.             Response.Write("<script>alert ('Data Saved.')</script>")
    4.         Else
    5.             'Show an error message.
    6.             Response.Write("<script>alert ('ERROR! There was an error saving the data.')</script>")
    7.         End If

    Smart navigation in the Web.Config:
    Code:
    <configuration>
      <system.web>
    	<!--	SMART NAVIGATION
    			This is for smart navigation in the web application.-->
    	<pages smartNavigation="true" />
      </system.web>
    </configuration>

  2. #2

    Thread Starter
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Bump...

    It is kind of important for me to understand why this is happening so I can work around it if possible....

  3. #3

    Thread Starter
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Last bump...

  4. #4
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    There are known issues with SmartNavigation causing problems with client-side javascript, such as setting focus to controls, style sheets on post-back, etc...

    What javascript error are you getting?

    Have you tried using Page.RegisterStartupScript?
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  5. #5
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    Maybe something like this would work?
    VB Code:
    1. If blnReturn Then
    2.    Call AlertUser("Data Saved")
    3. Else
    4.    Call AlertUser("ERROR! There was an error saving the data.")
    5. End If
    6.  
    7.  
    8. Public Sub AlertUser(ByVal strMessage As String)
    9.    Dim strScript As String
    10.  
    11.    strScript = "<script>"
    12.    strScript = strScript & "alert(" & strMessage & ");"
    13.    strScript = strScript & "</script>"
    14.  
    15.    Page.RegisterStartupScript("ClientScript", strScript)
    16. End Sub
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  6. #6

    Thread Starter
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Thanks!!!!!!

    Your solution works, but to others that use this, you have to change one line of code to add quotes around the message. Example:
    Code:
    strScript = strScript & "alert('" & strMessage & "');"

    Thanks a ton.

  7. #7
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    I know this thread is old but...

    Long ago we had attempted SmartNavigation in our web application, but for some unknown reason took it back out.

    Then just today, I put it back in... worked like a charm... for about 5 minutes....

    You see every 1.5 mins or so, our main app page posts back via a javascript timer...

    It appears that with smartnavigation enabled, the timers never get disposed (worse seem to multiply!), so it keeps building more timers on each postback... my god, there must have been 9 timers all at different points in time sending requests.

    It was very ugly!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width