1

i have the following Ajax.actionlink to perform a deletion:-

@Ajax.ActionLink("Delete", "Delete", "Answer", 
        new { id = answer.AnswersID }, 
          new AjaxOptions 
          { 
              Confirm = "Are You sure You want to delete this Answer ?", 
              HttpMethod = "Post", 
              UpdateTargetId = @answer.AnswersID.ToString(), 
              OnSuccess = "removePartial2", 
          }) 

and the following removePartial2 java script that will be called Onsuccess:-

<script type="text/javascript"> 
    function removePartial2() { 
        alert('Deletion was successful');  
        $(this).remove(); 
} 
</script>

currently both the Confirm = "Are You sure You want to delete this Answer ?", & the alert('Deletion was successful'); alerts are being displayed with a non-user friendly alerts that looks like these are error messages and not confirmation messages so i have the following two questions:

  1. how can i modify the look and feel (colors & text) and provide customized java scripts alerts.

  2. how i pass the answer.Description for the object that will be deleted to be displayed as part of the alert message?

Edited:- i tried the Bootsrap alerts as they look cool, but when i navigate to the intended view i got the following error "Microsoft JScript runtime error: Object doesn't support property or method 'on'" on the "$('body').on('click.alert.data-api', dismiss, Alert.prototype.close)" inside the bootstrap-alert.js file. so what might cause the problem?

2
  • for 1 there are a number of jQuery plugins that replace the default alert/confirm entirely. Google around! Commented Mar 8, 2012 at 23:31
  • You can't change alert and confirm popups, as they are provided by the browser. Use custom ones instead (jQueryUI, or others) Commented Mar 8, 2012 at 23:34

1 Answer 1

1

Instead of using the alert dialog, you could use a modal or just add a little notification element to your page. I'd recommend using something like the Bootsrap alerts; they look great and are easy to implement.

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

3 Comments

i tried the Bootsrap alerts as they look cool, but when i navigate to the intended view i got the following error "Microsoft JScript runtime error: Object doesn't support property or method 'on'" on the "$('body').on('click.alert.data-api', dismiss, Alert.prototype.close)" inside the bootstrap-alert.js file. so what might cause the problem?
@johnG: Looks like you're missing the jQuery dependency.
no i have included these scripts in the _layout view:- <script src="ajax.aspnetcdn.com/ajax/jQuery/jquery-1.6.2.min.js" type="text/javascript"></script> <script src="ajax.aspnetcdn.com/ajax/jquery.ui/1.8.14/jquery-ui.min.js" type="text/javascript"></script> <script src="ajax.aspnetcdn.com/ajax/mvc/3.0/jquery.unobtrusive-ajax.min.js" type="text/javascript"></script>

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.