John John
John John

Reputation: 1

how to create a customized java script alerts and pass it an object property inside my asp.net MVC

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?

Upvotes: 1

Views: 370

Answers (1)

Esteban Araya
Esteban Araya

Reputation: 29664

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.

Upvotes: 1

Related Questions