Confirm box on Page_load

T

tshad

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
 
M

Mark Rae

<script type="text/javascript">
function CheckForProfile()
{
if(confirm("Do you want to enter a profile?"))
{
window.location=" /applicant/passport.aspx";
}
}
</script>
 
J

John Timney \(MVP\)

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 said:
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');}<"
 
T

tshad

That was it.

Thanks,

Tom
John Timney (MVP) said:
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






var ret = confirm("Do you want to Enter a Profile?");
if (ret) {window.alert('yes');"
else
window.alert('No');}<"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top