473,467 Members | 1,587 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Basic Script Not Working in ASP.Net Page

Looking to do something pretty simple... I have a cancel button on my page.
When the user clicks it, i want to verify they want to cancel and if so,
redirect them.

Code:
-------------------------------------------------------------
<html>
<script language=vbscript>
if MsgBox("Testing",4) = 6 Then
window.location = "http://www.google.com"
End if
</script>
</html>
--------------------------------------------------------------

This code works just fine like that, but when I place it in a sub procedure
and call it in response to an onclick event, the redirect never happens. I
even placed an alert box in the if block ot verify that I was getting into
the block. I got the alert, but no redirect. Why doesn't this work in
repsonse to an onclick event, but it deos work by itself in a separate page?
Thanks.

Jerry



Jan 9 '06 #1
5 1418
well, this should be on a javascript thread but I aswer you
do a return false to the event, cause the button is posting the form
the and redirect is never happening

Jan 9 '06 #2
Are you talking about an actual server-side onClick event handler in
ASP.NET?

Your code is running client-side, instead of using JavaScript, you are using
VBScript, but it's still client-side (running in the browser). A server
side method can't call a client-side one.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
<rl*****@newsgroups.nospam> wrote in message
news:Of**************@tk2msftngp13.phx.gbl...
Looking to do something pretty simple... I have a cancel button on my
page.
When the user clicks it, i want to verify they want to cancel and if so,
redirect them.

Code:
-------------------------------------------------------------
<html>
<script language=vbscript>
if MsgBox("Testing",4) = 6 Then
window.location = "http://www.google.com"
End if
</script>
</html>
--------------------------------------------------------------

This code works just fine like that, but when I place it in a sub
procedure
and call it in response to an onclick event, the redirect never happens.
I
even placed an alert box in the if block ot verify that I was getting into
the block. I got the alert, but no redirect. Why doesn't this work in
repsonse to an onclick event, but it deos work by itself in a separate
page?
Thanks.

Jerry



Jan 9 '06 #3
Karl - This is supposed to be client side stuff. There is no need to post
back to the server if the client is not interested in canceling the
transaction. The onclick event is calling a client side sub defined in a
script block.

Henrique - This is being done in vbscript because the javascript
confirmation dialog doesn't allow you to specify the text on the buttons and
it can get confusing for an end user to confirm cancelation with an Okay
button and Cancel cancelation with a "Cancel" button which is what they used
to get the confirmation window to begin with. With the vbscript messagebox
I can display Yes and No buttons instead.

So the problem seems to be that the input element is causing a postback
which is canceling the redirect?

Is there a way in VBscript to keep this from happening so I can keep my Yes
and No buttons.

I'm really not interested in creating a custom dialog for this so I can make
it more user friendly with javascript...

Thanks for the responses.

Jerry

<rl*****@newsgroups.nospam> wrote in message
news:Of**************@tk2msftngp13.phx.gbl...
Looking to do something pretty simple... I have a cancel button on my page. When the user clicks it, i want to verify they want to cancel and if so,
redirect them.

Code:
-------------------------------------------------------------
<html>
<script language=vbscript>
if MsgBox("Testing",4) = 6 Then
window.location = "http://www.google.com"
End if
</script>
</html>
--------------------------------------------------------------

This code works just fine like that, but when I place it in a sub procedure and call it in response to an onclick event, the redirect never happens. I even placed an alert box in the if block ot verify that I was getting into
the block. I got the alert, but no redirect. Why doesn't this work in
repsonse to an onclick event, but it deos work by itself in a separate page? Thanks.

Jerry



Jan 9 '06 #4
Well, you have to make if a function that return false always to the
event so the post back wont happen

Jan 9 '06 #5
Right... But I can't seem to find a way to make that happen in VBScript.
I've worked around it by having a JavaScript function call the VBScript
function.

The VBScript shows the dialog the way I want it to appear and the JavaScript
returns the value the way the browser needs it.

A bit klunky, perhaps, but it works.

"Henrique Mello" <hm****@gmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
Well, you have to make if a function that return false always to the
event so the post back wont happen

Jan 9 '06 #6

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

Similar topics

12
by: bhennon | last post by:
Hey all, I have a small php script that calls a random image at the following page. http://www.2006ymcanationals.com/random.php IT WORKS IF I go directly to the above link. I am trying to...
7
by: Michael Foord | last post by:
#!/usr/bin/python -u # 15-09-04 # v1.0.0 # auth_example.py # A simple script manually demonstrating basic authentication. # Copyright Michael Foord # Free to use, modify and relicense. #...
1
by: Brian Tozer | last post by:
I have put a stationery page that I am working on online at:- http://homepages.ihug.co.nz/~briantoz/stolenkiss/stolenkiss3.html Although there is a bug that causes it to only display the top half...
12
by: Mark Fox | last post by:
Hello, I am attempting to do something very simple. I have a page MainPage.aspx and a popup window Popup.aspx. When users click on the linkbutton in the popup window I am looking to do some...
8
by: Fabrizio Cyber | last post by:
Hi all, I want to use a .js into a visual basic project. How can I do it ? I've tried to open the script code into my project....and then ??? I see the code but I don't jnow how to make it...
13
by: usenet | last post by:
How and where can one find out about the basics of VB/Access2003 syntax? I am a died in the wool C/C++/Java Linux/Unix programmer and I am finding it difficult to understand the program format...
2
by: craig.burrell | last post by:
I'm not a Javascript programmer, and I have a basic question about how scripts may make use of libraries in Javascript. I thank everyone for humouring me. Do all of the libraries required by a...
4
by: Goran Djuranovic | last post by:
Hi all, I am experiencing a strange thing happening with a "designer.vb" page. Controls I manually declare in this page are automatically deleted after I drop another control on a ".aspx" page. -...
12
by: OccasionalFlyer | last post by:
I am pretty new to JavaScript and having trouble with something that should, I think, be fairly easy. I have one form. I have two radio buttons. I have a text box that is hidden. If you click...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
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,...
0
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.