Hey Sivarjun,
I know of two ways how you can go about this :
ConfirmSave()
{
var Ok = confirm('Are you sure want to save the changes?');
if(Ok)
return true;
else
return false;
}
---------------------------------------//For redirection to the URL
function ConfirmCancel(URL)
{
var Ok = confirm('Are you sure want to Cancel the changes?');
if(Ok == true)
{
document.location.href=URL;
}
//else
//return false;
}
In server side you can add this line for adding attributes of onclick()
btnSave.Attributes["onclick"] = "javascript:return ConfirmSave();";
btnCancel.Attributes["onclick"] = "javascript:ConfirmCancel('InspectionNew.aspx');";
or you could try :
if (true)
{
}
else
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "open", "show();", true);
}
and in your page :
<script type="text/javascript">
function show()
{
if(confirm('r u sure?'))
{
window.location.replace('yourpage.aspx');
}
}
</script>
Hope this helps.