コード例 #1
0
        private static MvcHtmlString GetSocialLink(this HtmlHelper htmlHelper, SocialFeature feature)
        {
            var anchor = new TagBuilder("a");

            anchor.MergeAttribute("class", "social-link");
            anchor.MergeAttribute("href", BuildUrl(feature));
            anchor.MergeAttribute("target", "_blank");
            anchor.InnerHtml = GetSocialImage(htmlHelper, feature);

            return(MvcHtmlString.Create(anchor.ToString()));
        }
コード例 #2
0
        private static string GetSocialImage(this HtmlHelper htmlHelper, SocialFeature feature)
        {
            var img = new TagBuilder("img");

            var urlHelper = new UrlHelper(htmlHelper.ViewContext.RequestContext);

            img.MergeAttribute("class", "pop rollover");
            img.MergeAttribute("src", urlHelper.Content(string.Format("~/Content/Images/social_icons/{0}.png", feature.FeatureImagePart)));
            img.MergeAttribute("data-rollover", urlHelper.Content(string.Format("~/Content/Images/social_icons/{0}-hover.png", feature.FeatureImagePart)));
            img.MergeAttribute("alt", feature.FeatureImagePart);

            return(MvcHtmlString.Create(img.ToString()).ToHtmlString());
        }
コード例 #3
0
        private static string BuildUrl(SocialFeature feature)
        {
            const string format = "http://www.{0}.com/{1}";

            return(string.Format(format, feature.FeatureImagePart, feature.FeatureValue));
        }