473,395 Members | 1,379 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,395 software developers and data experts.

Confirm box on Page_load

Is there a way to do a Javascript confirm box when an aspx page initially
loads (not postback)?

I can make the confirm box come up by doing the following:
************************************************** *
<script type="text/javascript">
function CheckForProfile() {
confirm("Do you want to Enter a Profile?");
}
</script>

Sub Page_load()
if not isPostBack then
myBody.Attributes.Add("onload","CheckForProfile(); ")
end if
end sub

<body id="myBody" runat="server">
**************************************************

But I want to have the user redirect to "/applicant/passport.aspx" if they
push the OK button and just continue on if they press the cancel.

Is there a way to do this?

The confirm window comes up fine but how to I get it to jump to another
page?

Thanks,

Tom
Mar 22 '07 #1
3 1893
"tshad" <t@home.comwrote in message
news:uu**************@TK2MSFTNGP03.phx.gbl...

<script type="text/javascript">
function CheckForProfile()
{
if(confirm("Do you want to enter a profile?"))
{
window.location=" /applicant/passport.aspx";
}
}
</script>
Mar 22 '07 #2
Change your function to one that evaluates the return from confirm....and
then does a windows.location to your URL - you might need to fiddle with the
code a bit as I'm tired :0)

function CheckForProfile() {
var ret = confirm("Do you want to Enter a Profile?");
if (ret) {
window.location=http://www.someplace.com;
window.alert('yes');"
else
window.alert('No');
}
}

Regards

John Timney (MVP)
http://www.johntimney.com
http://www.johntimney.com/blog

"tshad" <t@home.comwrote in message
news:uu**************@TK2MSFTNGP03.phx.gbl...
Is there a way to do a Javascript confirm box when an aspx page initially
loads (not postback)?

I can make the confirm box come up by doing the following:
************************************************** *
<script type="text/javascript">
function CheckForProfile() {
var ret = confirm("Do you want to Enter a Profile?");
if (ret) {window.alert('yes');"
else
window.alert('No');}<"
}
</script>

Sub Page_load()
if not isPostBack then
myBody.Attributes.Add("onload","CheckForProfile(); ")
end if
end sub

<body id="myBody" runat="server">
**************************************************

But I want to have the user redirect to "/applicant/passport.aspx" if they
push the OK button and just continue on if they press the cancel.

Is there a way to do this?

The confirm window comes up fine but how to I get it to jump to another
page?

Thanks,

Tom

Mar 22 '07 #3
That was it.

Thanks,

Tom
"John Timney (MVP)" <x_****@timney.eclipse.co.ukwrote in message
news:9-******************************@eclipse.net.uk...
Change your function to one that evaluates the return from confirm....and
then does a windows.location to your URL - you might need to fiddle with
the code a bit as I'm tired :0)

function CheckForProfile() {
var ret = confirm("Do you want to Enter a Profile?");
if (ret) {
window.location=http://www.someplace.com;
window.alert('yes');"
else
window.alert('No');
}
}

Regards

John Timney (MVP)
http://www.johntimney.com
http://www.johntimney.com/blog

"tshad" <t@home.comwrote in message
news:uu**************@TK2MSFTNGP03.phx.gbl...
>Is there a way to do a Javascript confirm box when an aspx page initially
loads (not postback)?

I can make the confirm box come up by doing the following:
************************************************* **
<script type="text/javascript">
function CheckForProfile() {
var ret = confirm("Do you want to Enter a Profile?");
if (ret) {window.alert('yes');"
else
window.alert('No');}<"
> }
</script>

Sub Page_load()
if not isPostBack then
myBody.Attributes.Add("onload","CheckForProfile(); ")
end if
end sub

<body id="myBody" runat="server">
************************************************* *

But I want to have the user redirect to "/applicant/passport.aspx" if
they push the OK button and just continue on if they press the cancel.

Is there a way to do this?

The confirm window comes up fine but how to I get it to jump to another
page?

Thanks,

Tom


Mar 23 '07 #4

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

Similar topics

5
by: Logger | last post by:
Help, I’m trying to implement a confirm button on an asp.net page. I have it attached to a asp:button control. In the button1 click event I call the CreateConfirmBox subroutine. The Box comes...
1
by: Billy | last post by:
Hi... I have a problem with a confirm dialog box. I want to execute some code and then prompt the user with a confirm dialog box who's message will depend on the result of the execution from...
7
by: Grey | last post by:
how to design confirm message box, like Javascript Confirm box, in ASP.NET?? if the user click "YES" in the confirm box, i need to do something, else do other things. Do I need to have javascript...
0
by: Chris Fink | last post by:
My goal is to have an ASP.NET checkbox server tag with it's autopostback set to true, that when clicked will run the checkbox's CheckedChanged event. However, I would like to try to add a...
7
by: TJS | last post by:
javascript "confirm" fires after deletion instead of before deletion. how do I get this to stop the processing ? code ================== Sub ShowAlert(ByVal s As string)...
1
by: freshRecruit | last post by:
Hi, I am having a problem, and is driving me nuts and my deadline is fast approaching. Please do help me.. This is a webapplication with a usercontrol which has some buttons for adding,...
3
by: enzo | last post by:
I'm using asp.net 2.0 I have a checkbox with server checkedCanged event . I must add a confirm on click event. I have used this : myCheckBox.Attributes.Add("onClick", "return...
8
by: rn5a | last post by:
I have gone through a no. of posts in this NewsGroup regarding my problem but alas, couldn't come across one which would have helped me in resolving the issue. My problem is this: An ASPX Form...
4
by: mamun | last post by:
Hi All, I have the following situation and am looking for answer in C#. I have a datagrid and putting checkbox next to each record. In the header I have a Delete button. I want users to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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,...
0
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...
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...

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.