473,323 Members | 1,560 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

Javascript location.href not working

Here is my code created when a page loads the first time:

string jScript =
@"

<script
language='javaScript'>
var pop = false;
function
CancelPage()
{
var ans =
false;
ans =
confirm('Are you sure you want to Cancel and lose any
changes?');
if (ans)
{

alert('yes');

parent.location.href = 'OrderMisc.aspx';
}
}
</script>";

if ( !IsStartupScriptRegistered
("CancelPage") )
RegisterStartupScript
("CancelPage", jScript);

btnCancel.Attributes.Add
("onclick","javascript: pop=true;CancelPage();");
++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++

Code is called correctly when the Cancel button is
pressed because I get the confirmation box, I click yes
and I get the alert box from the code, then the page
reloads without redirecting to 'OrderMaint.aspx'.

OrderMaint.aspx is spelled correctly and in the same
directory so I'm not sure why it's not taking me there.

Any ideas?

Thanks,
Darin
Nov 18 '05 #1
1 2350
Hi,

If button is asp.net server control or HTML submit button you need to
cancel it default behavior by cancel event bubbling and returning false
from your javascript function:

window.event.returnValue = false;
window.event.cancelBubble = true;
Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #2

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

Similar topics

5
by: splatter | last post by:
Hey all, I'm trying to get a java bookmark to work from my browsers address field which is supposed to send a prefix + reload the current page from my proxy & return a special view depending...
3
by: DCB | last post by:
Hello. I have an easy question, likely, that has me in a headspin. I have an include file to a frames based site that basically forces frames on the end user if they visit the site and hit a...
2
by: Jackson Yap | last post by:
can someone kind enough to help me look at the attached html and js file? Why is it that the javascript menu could not work at www.apchosting.net but could work at...
7
by: e | last post by:
I've been having an extremely difficult time finding an answer to this in IE / js groups, so I thought I'd try here. I've got an aspx page that delivers loads of report data into custom-named...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.