You either create a new extension method that returns the MvcHtmlString object that you put together (for example, html encoding), we create a partial view that you can display when you need it, t you need to create HTML through the code.
public static class MyHtmlExtensions { public static MvcHtmlString MyActionLink(this HtmlHelper html, string action, string controller, string ajaxUpdateId, string spanText) { var url = UrlHelper.GenerateContentUrl("~/" + controller + "/" + action); var result = new StringBuilder(); result.Append("<a href=\""); result.Append(HttpUtility.HtmlAttributeEncode(url)); result.Append("\" data-ajax-update=\""); result.Append(HttpUtility.HtmlAttributeEncode("#" + ajaxUpdateId));
source share