javascript yes no button

M

mark

i have a public boolean variable called exit - it should run like this

if variable = true then (javascript msgbox with you havent saved would you
like to yes/no)
if no then Response.Redirect("index.aspx")

cheers

mark
 
S

Simon Gorski

Hello Mark,
mark said:
i have a public boolean variable called exit - it should run like this

if variable = true then (javascript msgbox with you havent saved would you
like to yes/no)
if no then Response.Redirect("index.aspx")
if variable = true then
Page.RegisterClientScriptBlock("jsPopUp","<script
language='javascript'>answer = confirm('Save?') <script>");
end if

mfg simon g.
 
M

mark

thanks but that doesnt appear to do anything!

ive the line :-

RegisterStartupScript("startupScript", "<script
language=JavaScript>confirm('you have unsaved data - click yes to
save');</script>")
just need to know how to process the yes no clicks
btw im using codebehind and aspx

thanks

mark
 
S

Simon Gorski

Hello Mark,
mark said:
thanks but that doesnt appear to do anything!

ive the line :-

RegisterStartupScript("startupScript", "<script
language=JavaScript>confirm('you have unsaved data - click yes to
save');</script>")
just need to know how to process the yes no clicks
btw im using codebehind and aspx

1. make a input type-hidden value (id=hdnSave)
2. make a js- function Save()
{
myValue = confirm('you have unsaved data -click yes to save')
if (myValue)
{
window.document.getElementById('hdnSave').value = 1;
}
else
{
window.document.getElementById('hdnSave').value = 1;
}

}
3. Add the Script to the Button
btnNext.Attributes.Add("onClick","Save()");
4. Ask CodeBehind
if (hdnSave.Value=="1")
//Save
else
//do what you like

mfg simon g.
 
M

mark

thanks ill give that a try

mark

Simon Gorski > said:
Hello Mark,


1. make a input type-hidden value (id=hdnSave)
2. make a js- function Save()
{
myValue = confirm('you have unsaved data -click yes to save')
if (myValue)
{
window.document.getElementById('hdnSave').value = 1;
}
else
{
window.document.getElementById('hdnSave').value = 1;
}

}
3. Add the Script to the Button
btnNext.Attributes.Add("onClick","Save()");
4. Ask CodeBehind
if (hdnSave.Value=="1")
//Save
else
//do what you like

mfg simon g.
 

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

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top