Reputation: 13956
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?
Upvotes: 0
Views: 260
Reputation: 2971
Yes Ajax is the best.
You can also do via JavaScript as well using
location.href = newPageUrl;
mostly in redirection Scenario
Upvotes: 0
Reputation: 943152
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.
Upvotes: 1
Reputation: 14672
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
Upvotes: 1