javascript yes no button

  • Thread starter Thread starter mark
  • Start date Start date
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
 
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.
 
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
 
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.
 
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.
 
Back
Top