views:

465

answers:

2

I'm wanting to have a simple cancel button so on confirmation of, say, the deletion of a product, they can change their mind and click cancel before the actual delete action is started.

I figure that on clicking the button you are wanting to redirect the user to the previous page. I understand that a common way to handle this is with javascript

onclick="javascript:history.back(1);"

Is this acceptable? If the user has javascript disabled, what happens then?

So instead, I figured that I would submit the form and an action would redirect the user to the previous page. Is this how it should be done? And if so, what is the C# code to do this?

Thanks for any help :)

+1  A: 

Might be better if you do a jQuery postback to a controller event which can then send a cancel event to the object doing the processing.

if you make your processing object run async then you can have a cancel method which would then set say a flag which is checked each time around the processing loop or whatever it is you have.

I think just going back is a little dangerous in that the opperation may not actually stop.

griegs
as specified in the first paragraph edit, processing has not started yet
ajbeaven
Yeah I read that after posting my answer. Sorry
griegs
+1  A: 

the only way you can do this without javascript is if you make a second form that POSTs to a different action (that will just redirect you) that just has a single submit button with cancel text.

If you are doing a web application, it is pretty much expected that javascript is a requirement. As far as I'm concerned, anyone who chooses to live without javascript nowadays is choosing to live with a broken internet, and it has been a very long time since browsers did not support it. The whole idea is just silly to me, sort of like the people who block cookies.

Matt Briggs