0

I have this situation: I have an asp page that have a form and an action button. When user click button, it must show a confirmation box (confirm) to ask user. If user say OK it must do action A, and if user say Cancel it must do action B. The problem is that A,B action is on server-side and user are on client side. Because it require 2 action so I cannot add return confirm() into onclick attribute. So I what I've done is create a hidden field in the form and write javascript function that ask user and return value in hidden field and submit form then take action on server based on hidden field.

My question is: Is there any better design for this case?

1
  • you can do same thing by ajax request. Commented Aug 8, 2012 at 9:30

3 Answers 3

1

Yes, at least in my opinion, it is worth taking a look at the ajax control toolkit, in particular:

http://www.asp.net/ajaxlibrary/act_Popup.ashx

Sign up to request clarification or add additional context in comments.

Comments

1

Use two buttons in the form instead of asking after the form is submitted.

<input type="submit" name="action" value="OK">
<input type="submit" name="action" value="Cancel">

Only the clicked one will be successful.

1 Comment

This used to be one of my solution before
0

Yes Ajax is the best.

You can also do via JavaScript as well using

location.href = newPageUrl; 

mostly in redirection Scenario

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.