473,785 Members | 2,842 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Javascript alerts - work on some pages but not on others

Hi,

I am attempting to display a simple Javascript alert when a webpage
loads. It works on some pages but not on others. For example, the
following code does not produce an alert:

Code in webpage1 (note, this is the only VB code in the ASPNET
webpage, in other words, the rest is all HTML):

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here

If Not IsPostBack Then
Dim str As String = "<script
language=javasc ript>alert('Hel lo');</script>"
Page.RegisterSt artupScript("St artup", str)
End If
End Sub

However, the same code on a different page produces an alert:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
If Not EventLog.Source Exists("Buildin g Portal") Then
EventLog.Create EventSource("Bu ilding Portal",
"Applicatio n")
End If
EventLog1.Sourc e = "Building Portal"
EventLog1.Log = "Applicatio n"

If Page.IsPostBack Then
'make checks to see if the user or email address is
already registered or in process of being registered
Call checkDetails()

Select Case True
Case bEmailExists
lblMessage.Text = "Email already exists! Please
select another"
bDoNotReg = True
Case bUserExists
lblMessage.Text = "Username already exists! Please
select another"
bDoNotReg = True
End Select
End If
End Sub

this page has a lot more VB code...

Please could someone explain why the alert should work on one page but
not the other? Is there some setting that needs setting (I don't
think there is since I haven't actually set one).

Thanks.

Jimmy

Mar 9 '07 #1
5 2227
On 9 Mar, 17:07, "thatsMaBoy " <jimmyfishb...@ yahoo.co.ukwrot e:
Hi,

I am attempting to display a simple Javascript alert when a webpage
loads. It works on some pages but not on others. For example, the
following code does not produce an alert:

Code in webpage1 (note, this is the only VB code in the ASPNET
webpage, in other words, the rest is all HTML):

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here

If Not IsPostBack Then
Dim str As String = "<script
language=javasc ript>alert('Hel lo');</script>"
Page.RegisterSt artupScript("St artup", str)
End If
End Sub

However, the same code on a different page produces an alert:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
If Not EventLog.Source Exists("Buildin g Portal") Then
EventLog.Create EventSource("Bu ilding Portal",
"Applicatio n")
End If
EventLog1.Sourc e = "Building Portal"
EventLog1.Log = "Applicatio n"

If Page.IsPostBack Then
'make checks to see if the user or email address is
already registered or in process of being registered
Call checkDetails()

Select Case True
Case bEmailExists
lblMessage.Text = "Email already exists! Please
select another"
bDoNotReg = True
Case bUserExists
lblMessage.Text = "Username already exists! Please
select another"
bDoNotReg = True
End Select
End If
End Sub

this page has a lot more VB code...

Please could someone explain why the alert should work on one page but
not the other? Is there some setting that needs setting (I don't
think there is since I haven't actually set one).

Thanks.

Jimmy
Apologies for my first post, the second webpage (in which the alert
works) should have contained the following code:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
If Not EventLog.Source Exists("Buildin g Portal") Then
EventLog.Create EventSource("Bu ilding Portal",
"Applicatio n")
End If
EventLog1.Sourc e = "Building Portal"
EventLog1.Log = "Applicatio n"

If Page.IsPostBack Then
Dim str As String = "<script
language=javasc ript>alert('Cli ck on the button?');</script>"
Page.RegisterSt artupScript("St artup", str)

'make checks to see if the user or email address is
already registered or in process of being registered
Call checkDetails()

Select Case True
Case bEmailExists
lblMessage.Text = "Email already exists! Please
select another"
bDoNotReg = True
Case bUserExists
lblMessage.Text = "Username already exists! Please
select another"
bDoNotReg = True
End Select
End If
End Sub

etc, etc, (i.e more code in page)

Thanks.

Mar 9 '07 #2

most likely you have a script error on the page. the first script error
cancels script processing. turn on script debugging in the browser.

-- bruce (sqlwork.com)

thatsMaBoy wrote:
Hi,

I am attempting to display a simple Javascript alert when a webpage
loads. It works on some pages but not on others. For example, the
following code does not produce an alert:

Code in webpage1 (note, this is the only VB code in the ASPNET
webpage, in other words, the rest is all HTML):

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here

If Not IsPostBack Then
Dim str As String = "<script
language=javasc ript>alert('Hel lo');</script>"
Page.RegisterSt artupScript("St artup", str)
End If
End Sub

However, the same code on a different page produces an alert:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
If Not EventLog.Source Exists("Buildin g Portal") Then
EventLog.Create EventSource("Bu ilding Portal",
"Applicatio n")
End If
EventLog1.Sourc e = "Building Portal"
EventLog1.Log = "Applicatio n"

If Page.IsPostBack Then
'make checks to see if the user or email address is
already registered or in process of being registered
Call checkDetails()

Select Case True
Case bEmailExists
lblMessage.Text = "Email already exists! Please
select another"
bDoNotReg = True
Case bUserExists
lblMessage.Text = "Username already exists! Please
select another"
bDoNotReg = True
End Select
End If
End Sub

this page has a lot more VB code...

Please could someone explain why the alert should work on one page but
not the other? Is there some setting that needs setting (I don't
think there is since I haven't actually set one).

Thanks.

Jimmy
Mar 9 '07 #3
Don't know if related but you used "If not IsPostBack" on one and "If
postback" on the other so it shouldn't be triggered at the same time in both
pages...

Also as this is a a client side problem an easy way to diagnose this would
be to use "view source" and check if the rendered HTML contains what you
expect...
"thatsMaBoy " <ji***********@ yahoo.co.uka écrit dans le message de news:
11************* *********@n33g2 00...legr oups.com...
Hi,

I am attempting to display a simple Javascript alert when a webpage
loads. It works on some pages but not on others. For example, the
following code does not produce an alert:

Code in webpage1 (note, this is the only VB code in the ASPNET
webpage, in other words, the rest is all HTML):

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here

If Not IsPostBack Then
Dim str As String = "<script
language=javasc ript>alert('Hel lo');</script>"
Page.RegisterSt artupScript("St artup", str)
End If
End Sub

However, the same code on a different page produces an alert:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
If Not EventLog.Source Exists("Buildin g Portal") Then
EventLog.Create EventSource("Bu ilding Portal",
"Applicatio n")
End If
EventLog1.Sourc e = "Building Portal"
EventLog1.Log = "Applicatio n"

If Page.IsPostBack Then
'make checks to see if the user or email address is
already registered or in process of being registered
Call checkDetails()

Select Case True
Case bEmailExists
lblMessage.Text = "Email already exists! Please
select another"
bDoNotReg = True
Case bUserExists
lblMessage.Text = "Username already exists! Please
select another"
bDoNotReg = True
End Select
End If
End Sub

this page has a lot more VB code...

Please could someone explain why the alert should work on one page but
not the other? Is there some setting that needs setting (I don't
think there is since I haven't actually set one).

Thanks.

Jimmy

Mar 9 '07 #4
Are you using RegisterStartup Script anywhere else on the page? I could be
wrong about this, but the first parameter to that method is supposed to be a
unique to what you are trying to register. "Startup", then, in your
example, would not properly register if you used that unique string to
register some other startup script. You aren't allowed to overwrite.

"thatsMaBoy " <ji***********@ yahoo.co.ukwrot e in message
news:11******** **************@ n33g2000cwc.goo glegroups.com.. .
Hi,

I am attempting to display a simple Javascript alert when a webpage
loads. It works on some pages but not on others. For example, the
following code does not produce an alert:

Code in webpage1 (note, this is the only VB code in the ASPNET
webpage, in other words, the rest is all HTML):

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here

If Not IsPostBack Then
Dim str As String = "<script
language=javasc ript>alert('Hel lo');</script>"
Page.RegisterSt artupScript("St artup", str)
End If
End Sub

However, the same code on a different page produces an alert:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
If Not EventLog.Source Exists("Buildin g Portal") Then
EventLog.Create EventSource("Bu ilding Portal",
"Applicatio n")
End If
EventLog1.Sourc e = "Building Portal"
EventLog1.Log = "Applicatio n"

If Page.IsPostBack Then
'make checks to see if the user or email address is
already registered or in process of being registered
Call checkDetails()

Select Case True
Case bEmailExists
lblMessage.Text = "Email already exists! Please
select another"
bDoNotReg = True
Case bUserExists
lblMessage.Text = "Username already exists! Please
select another"
bDoNotReg = True
End Select
End If
End Sub

this page has a lot more VB code...

Please could someone explain why the alert should work on one page but
not the other? Is there some setting that needs setting (I don't
think there is since I haven't actually set one).

Thanks.

Jimmy

Mar 9 '07 #5
On 9 Mar, 20:47, "Random" <cipher...@hotm ail.comwrote:
Are you using RegisterStartup Script anywhere else on the page? I could be
wrong about this, but the first parameter to that method is supposed to be a
unique to what you are trying to register. "Startup", then, in your
example, would not properly register if you used that unique string to
register some other startup script. You aren't allowed to overwrite.

"thatsMaBoy " <jimmyfishb...@ yahoo.co.ukwrot e in message

news:11******** **************@ n33g2000cwc.goo glegroups.com.. .
Hi,
I am attempting to display a simple Javascript alert when a webpage
loads. It works on some pages but not on others. For example, the
following code does not produce an alert:
Code in webpage1 (note, this is the only VB code in the ASPNET
webpage, in other words, the rest is all HTML):
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
If Not IsPostBack Then
Dim str As String = "<script
language=javasc ript>alert('Hel lo');</script>"
Page.RegisterSt artupScript("St artup", str)
End If
End Sub
However, the same code on a different page produces an alert:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
If Not EventLog.Source Exists("Buildin g Portal") Then
EventLog.Create EventSource("Bu ilding Portal",
"Applicatio n")
End If
EventLog1.Sourc e = "Building Portal"
EventLog1.Log = "Applicatio n"
If Page.IsPostBack Then
'make checks to see if the user or email address is
already registered or in process of being registered
Call checkDetails()
Select Case True
Case bEmailExists
lblMessage.Text = "Email already exists! Please
select another"
bDoNotReg = True
Case bUserExists
lblMessage.Text = "Username already exists! Please
select another"
bDoNotReg = True
End Select
End If
End Sub
this page has a lot more VB code...
Please could someone explain why the alert should work on one page but
not the other? Is there some setting that needs setting (I don't
think there is since I haven't actually set one).
Thanks.
Jimmy
Thanks for the replies/suggestions. RegisterStartup Script is only
used once on the page that works, and also only once on the page that
does not work. They are also registered with different names (i.e.
"Startup" and "SomethingElse" ).

I have checked the generated source and find that the Javascript code
is not present in the page that does not work (hardly surprising).

I have also tried changing from NOT PAGE.ISPOSTBACK to PAGE.ISPOSTBACK
(and vice versa) for the code that registers the Javascript, but still
no joy.

Thanks.

Jimmy

Mar 13 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1538
by: ryan baldwin | last post by:
Hi, I posted this in the GotDotNet .NET Alerts forum, but that was 3 days ago and still no reply so I'll try my luck here. My apologies if there's a better group to post this question in, but at last check there was no Alerts group. I've been reading through oodles of the SGK documentation for the .NET Alerts SDK 5.02, and something struck me in the Compliance Criteria section: "6. All of your pages work on Netscape version 4.7 or...
14
5486
by: tshad | last post by:
I posted this on the asp.net group, also. I wasn't sure whether this was an asp.net problem or a javascript problem. I have a page that was originally created from a program I found on the net that works well as an html page. It brings up a modal popup window that I have been trying to work out for days now and this was the closest I have been able to come. I added a little asp.net code and an asp.net button and cannot get it to
15
4231
by: binnyva | last post by:
Hello Everyone, I have just compleated a JavaScript tutorial and publishing the draft(or the beta version, as I like to call it) for review. This is not open to public yet. The Tutorial is avaliable at... http://www.geocities.com/binnyva/code/javascript/advanced_tutorial/ If any of you could spare the time, please have a look at my tutorial
136
9457
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their code was littered with document.all and eval, for example, and I wanted to create a practical list of best practices that they could easily put to use. The above URL is version 1.0 (draft) that resulted. IMO, it is not a replacement for the FAQ,...
9
4491
by: Cerebral Believer | last post by:
Hi folks, I am having some issues using a program that protects my web pages (to a degree) using JavaScript (to print screen/disable clipboard, caching text selection etc). Below is the code for the page after it has been encrypted on the local machine: <!--hppage status="protected"--> <!--Source code not available.--> <html>
2
1680
by: Bhasker V Kode | last post by:
Hi, I just wanted to share with everyone a new project that i'm launching today called the Returnable Project ( http://returnable.org ) Returnable serves as a open-platform architectural guide to advance the use of the URL as a DSL for specifying 3 traits : content,its delivery ,and its behaviour on the web through the use of Returnable elements embedded within web pages .
1
25700
pbmods
by: pbmods | last post by:
VARIABLE SCOPE IN JAVASCRIPT LEVEL: BEGINNER/INTERMEDIATE (INTERMEDIATE STUFF IN ) PREREQS: VARIABLES First off, what the heck is 'scope' (the kind that doesn't help kill the germs that cause bad breath)? Scope describes the context in which a variable can be used. For example, if a variable's scope is a certain function, then that variable can only be used in that function. If you were to try to access that variable anywhere else in...
60
5038
by: marss | last post by:
Maybe anyone know good free online JavaScript knowledge test? This not exactly a system for testing online required - it may be simply list of questions with variants of answers (I have to prepare tests for learners and I need something to be taken as basis). I was able to find only this (http://www.w3schools.com/js/ js_quiz.asp), but I need more. Thanks, Mykola
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10327
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10092
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8973
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7499
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6740
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3647
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2879
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.