473,654 Members | 3,108 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

conditionally run Javascript alert

In the middle of my event handler (for a button), I have an if/then
statement (using vb.net):
if (whatever) then
strScript="<scr ipt .......
strScript &= alert('This is an alert')
strscript &="</script>
' this is all an abbreviated script - - but you get the idea
response.write( strscript)
end if
response.redire ct("another page.aspx")

the problem is that, with the Response.redire ct after the if/then statement,
it skips the javascript alert and goes to the redirect
if I comment out the reponse.redirec t, the javascript alert pops up fine

where am I going wrong?
Mar 18 '08 #1
2 1967
You need to put your alert on the page you are redirecting to. By adding a
querystring "hasAlert" or something, you can check to see if you need to show
the alert on the next page.

"Seth Williams" wrote:
In the middle of my event handler (for a button), I have an if/then
statement (using vb.net):
if (whatever) then
strScript="<scr ipt .......
strScript &= alert('This is an alert')
strscript &="</script>
' this is all an abbreviated script - - but you get the idea
response.write( strscript)
end if
response.redire ct("another page.aspx")

the problem is that, with the Response.redire ct after the if/then statement,
it skips the javascript alert and goes to the redirect
if I comment out the reponse.redirec t, the javascript alert pops up fine

where am I going wrong?
Mar 18 '08 #2
Or you can do the redirect in javascript with location.href=' yourpage.aspx'

--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net

"Seth Williams" <sm@here.comwro te in message
news:%2******** ********@TK2MSF TNGP05.phx.gbl. ..
In the middle of my event handler (for a button), I have an if/then
statement (using vb.net):
if (whatever) then
strScript="<scr ipt .......
strScript &= alert('This is an alert')
strscript &="</script>
' this is all an abbreviated script - - but you get the idea
response.write( strscript)
end if
response.redire ct("another page.aspx")

the problem is that, with the Response.redire ct after the if/then
statement, it skips the javascript alert and goes to the redirect
if I comment out the reponse.redirec t, the javascript alert pops up fine

where am I going wrong?

Mar 19 '08 #3

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

Similar topics

0
7064
by: Gowhera Hussain | last post by:
Use This for Learning Only .... Do Not Try To Act Smart HACKING WITH JAVASCRIPT Dr_aMado Sun, 11 Apr 2004 16:40:13 UTC This tutorial is an overview of how javascript can be used to bypass simple/advanced html forms and how it can be used to override cookie/session
11
1634
by: Vincent van Beveren | last post by:
Hi everyone, I have the following code using inheritence The important part is the function getName(). The result should alert 'John Doe': function First(name) { this.name = name; this.getName = function() { return this.name;
7
1447
by: Bert Visscher | last post by:
Hello everyone, I would like to let visitors of my website be able to go directly to a desired page, by using a URL like www.example.com?progname. I thought I could do this as follows: <html> <frameset rows="88,*"> <frame name="head" noresize src="head.htm" /> <frameset cols="152,*">
14
5453
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
9
4906
by: tshad | last post by:
This is from my previous post, but a different issue. I have the following Javascript routine that opens a popup page, but doesn't seem to work if called from an asp.net button. It seems to work fine from a link. The button does bring up the popup window, but when I press the links on the page, it doesn't return or close the window. ****************************************************************************
1
25664
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...
8
3213
by: Pratik Patel | last post by:
Hello, I used innerHTML to assign HTML content. but in my HTML page content have also some javascript function and it will run when page load. bu when HTML code assgin thru innerHTML then this javascript is not working. e.g. html content:
5
1680
by: henry | last post by:
Basically, my php script runs on my serve all day along. If the php script finds something new, I'd like to get an email alert(which is done) and a cell phone alert, which has to be done through a "post" form (not through email). Can any one give me some hint on how to do this: conditionally submit a form without a button? I guess I need some javascript? Many thanks.
0
8372
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8814
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...
0
8706
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8591
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7304
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...
0
5621
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
4149
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4293
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1915
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.