36 lines
1.4 KiB
C#
36 lines
1.4 KiB
C#
using System.Collections.Generic;
|
|
using System.Text;
|
|
using System.Web.Mvc;
|
|
using Kreta.Framework;
|
|
|
|
namespace Kreta.Web.Helpers
|
|
{
|
|
public static class LinkExtensions
|
|
{
|
|
public static MvcHtmlString KretaLink(this HtmlHelper helper, int title, string href = "#", string classes = "", string content = "")
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.Append($"<a title=\"{StringResourcesUtil.GetString(title)}\" href=\"{href}\" class=\"{classes}\">{content}</a>");
|
|
|
|
MvcHtmlString str = new MvcHtmlString(sb.ToString());
|
|
return str;
|
|
}
|
|
|
|
public static MvcHtmlString KretaActionLink(this HtmlHelper helper, string title = "", string href = "#", string classes = "", string content = "", IDictionary<string, object> htmlAttributes = null)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
StringBuilder htmlAttributesString = new StringBuilder();
|
|
if (htmlAttributes != null)
|
|
{
|
|
foreach (KeyValuePair<string, object> item in htmlAttributes)
|
|
{
|
|
htmlAttributesString.Append($"{item.Key}=\"{item.Value}\" ");
|
|
}
|
|
}
|
|
sb.Append($"<a target=_blank title=\"{title}\" href=\"{href}\" class=\"{classes}\" {htmlAttributesString}>{content}</a>");
|
|
|
|
MvcHtmlString str = new MvcHtmlString(sb.ToString());
|
|
return str;
|
|
}
|
|
}
|
|
}
|