예제 #1
0
        public static MvcHtmlString CreateFacebookLikeButton(this HtmlHelper htmlHelper, string href, int width, int height, bool showFaces,bool send,
            FacebookLikeLayout layout, FacebookLikeFont font, FacebookLikeColorScheme colorScheme, FacebookLikeAction action)
        {
            string src = "";
            string widthValue = CalculateWidth(layout, width).ToString();
            string heightValue = CalculateHeight(layout, height).ToString();
            string layoutValue = layout.ToString().ToLower();
            string fontValue = GetFontValue(font);
            string actionValue = action.ToString().ToLower();
            string colorSchemeValue = colorScheme.ToString().ToLower();
            string showFacesValue = showFaces.ToString().ToLower();

            StringBuilder sb = new StringBuilder();
            sb.Append("http://www.facebook.com/plugins/like.php?app_id=225243224169155&href=");
            sb.Append(href + "&");
            if (send == true)
            {
                sb.Append("send=true&");
            }
            else
            {
                sb.Append("send=false&");
            }
            sb.Append("height=" + heightValue + "&");
            sb.Append("width=" + widthValue + "&");
            sb.Append("layout=" + layoutValue + "&");
            sb.Append("show_faces=" + showFacesValue + "&");
            sb.Append("action=" + actionValue + "&");
            sb.Append("colorscheme=" + colorSchemeValue + "&");
            sb.Append("font=" + fontValue);
            src = sb.ToString();

            TagBuilder iframe = new TagBuilder("iframe");
            iframe.Attributes["src"] = src;
            iframe.Attributes["scrolling"] = "no";
            iframe.Attributes["frameborder"] = "0";
            iframe.Attributes["style"] = "border:none; overflow:hidden; width:" + widthValue + "px; height:" + heightValue + "px;";
            iframe.Attributes["allowTransparency"] = "true";

            return MvcHtmlString.Create(iframe.ToString());
        }
예제 #2
0
        public static MvcHtmlString GetHtml(this HtmlHelper htmlHelper, string href, int width, int height, bool showFaces, FacebookLikeLayout layout, FacebookLikeFont font, FacebookLikeColorScheme colorScheme, FacebookLikeAction action)
        {
            /*
             <iframe
             * src="http://www.facebook.com/plugins/like.php?app_id=225243224169155&amp;
             *      href=http%3A%2F%2Fwww.yahoo.com&amp;
             *      send=false&amp;
             *      layout=standard&amp;
             *      width=450&amp;
             *      show_faces=true&amp;
             *      action=like&amp;
             *      colorscheme=light&amp;
             *      font=arial&amp;
             *      height=80"
            *      scrolling="no"
            *      frameborder="0"
            *      style="border:none; overflow:hidden; width:450px; height:80px;"
            *      allowTransparency="true">
             </iframe>*/
            StringBuilder src = new StringBuilder();
            src.Append("http://www.facebook.com/plugins/like.php?app_id=225243224169155&amp;href=");
            src.Append(HttpUtility.UrlEncode(href) + "&amp;");
            src.Append("send=false&amp;");
            src.Append("layout=" + layout.ToString().ToLower() + "&amp;");
            src.Append("show_faces=" + showFaces.ToString().ToLower() + "&amp;");
            src.Append("action=" + action.ToString().ToLower() + "&amp;");
            src.Append("colorscheme=" + colorScheme.ToString().ToLower() + "&amp;");
            src.Append("font=" + font.ToString().ToLower() + "&amp;");
            src.Append("height=" + height.ToString().ToLower());

            TagBuilder iframe = new TagBuilder("iframe");
            iframe.Attributes["src"] = src.ToString();
            iframe.Attributes["scrolling"] = "no";
            iframe.Attributes["frameborder"] = "0";
            iframe.Attributes["style"] = "border:none; overflow:hidden; width:450px; height:80px;";
            iframe.Attributes["allowTransparency"] = "true";

            return MvcHtmlString.Create(iframe.ToString());
        }