Getting confirmation from the user while clickig the delete button

liunx

Guest
Hai,

While displaying a record to the user, User can delete the record by clicking the "Delete" button. we need to get confirmation from the user to delete the record. For this we have to display the alert message to the user.

I am not able to call the javascript function and get return value from the function to the codebehind file.

If i am calling the javascript function and submit the form with the record id, it displays the below error.
---------------------------------------------------------------------
Server Error in '/sahmTest' Application.

The viewstate is invalid for this page and might be corrupted.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: The viewstate is invalid for this page and might be corrupted.

---------------------------------------------------------------------

Below is the javascript function

function verify(id)
{
if (confirm("Are you sure to delete?")==true)
{
document.Form1.method="post"
document.Form1.action="deleteform.aspx?id="+id;
document.Form1.submit();
____return true;
}
else
___return false;
}

and i had called the function as

btnDelete.Attributes.Add("onclick", "return verify(" & Id & ");")

Kindly suggest me. It is urgent.


Regards,
Siva RJavascript and a server side language are not going to communicate well. If you want some sort of js confirmation you might need to have js modify a query string. Another issue is that not everyone supports js so your confirmation with js will not work for everyone.Pls suggest me any alternate way to get confirmation before deleting the record.

Thanks,
SivaWell a second page with an are you sure button the user can click would be the most accessible and most reliable way. You might put this section of the site in an iframe maybe? (but remember to put an <a> tag between the <iframe></iframe> tags for accessibility).
 
Back
Top