Donate

Add Glyphicon To Ajax.ActionLink() In ASP.NET MVC

Good evening!
Adding a Bootstrap glyphicon to Ajax.ActionLink() helper is similar with Html.ActionLink() except that when the linkText parameter of the helper is empty, it will cause an Ajax issue and an Internal Server Error will be thrown from the browser. If you're going to integrate glyphicons on Ajax.ActionLink() helper and exclude the linkText property, supply that parameter with space instead of empty string so as not to cause jQuery or Ajax issues.
@Ajax.ActionLink(" ", "DeleteComment", "Home",
    new { id = comment.CommentID },
    new AjaxOptions
    {
     OnBegin = "return confirm('Are you sure you want to delete this comment?');",
     InsertionMode = InsertionMode.Replace,
     UpdateTargetId = "event-details-" + Model.Id,
     HttpMethod = "GET",                                  
    }, new 
    {  
     @class = "commentDelete glyphicon glyphicon-trash"
    });
linkText is the first parameter of Ajax.ActionLink() helper.
Output:
Add Glyphicon To Ajax.ActionLink() In ASP.NET MVC

Comments

Donate

Popular Posts From This Blog

WPF CRUD Application Using DataGrid, MVVM Pattern, Entity Framework, And C#.NET

Remove Cookies From CookieContainer Class

How To Test Or Check Dead Pixels And Backlight Bleed On Your Monitor Using Dead Pixel Checker In Windows 11