|
-
Feb 20th, 2004, 01:18 PM
#1
Thread Starter
PowerPoster
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:
If blnReturn Then
'Show a saved message.
Response.Write("<script>alert ('Data Saved.')</script>")
Else
'Show an error message.
Response.Write("<script>alert ('ERROR! There was an error saving the data.')</script>")
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>
-
Feb 22nd, 2004, 05:43 PM
#2
Thread Starter
PowerPoster
Bump...
It is kind of important for me to understand why this is happening so I can work around it if possible....
-
Feb 24th, 2004, 10:24 PM
#3
Thread Starter
PowerPoster
-
Feb 24th, 2004, 11:02 PM
#4
Frenzied Member
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
-
Feb 24th, 2004, 11:08 PM
#5
Frenzied Member
Maybe something like this would work?
VB Code:
If blnReturn Then
Call AlertUser("Data Saved")
Else
Call AlertUser("ERROR! There was an error saving the data.")
End If
Public Sub AlertUser(ByVal strMessage As String)
Dim strScript As String
strScript = "<script>"
strScript = strScript & "alert(" & strMessage & ");"
strScript = strScript & "</script>"
Page.RegisterStartupScript("ClientScript", strScript)
End Sub
Being educated does not make you intelligent.
Need a weekend getaway??? Come Visit
-
Feb 25th, 2004, 12:49 AM
#6
Thread Starter
PowerPoster
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.
-
Aug 19th, 2004, 12:21 PM
#7
I wonder how many charact
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|