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()); }
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& * href=http%3A%2F%2Fwww.yahoo.com& * send=false& * layout=standard& * width=450& * show_faces=true& * action=like& * colorscheme=light& * font=arial& * 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&href="); src.Append(HttpUtility.UrlEncode(href) + "&"); src.Append("send=false&"); src.Append("layout=" + layout.ToString().ToLower() + "&"); src.Append("show_faces=" + showFaces.ToString().ToLower() + "&"); src.Append("action=" + action.ToString().ToLower() + "&"); src.Append("colorscheme=" + colorScheme.ToString().ToLower() + "&"); src.Append("font=" + font.ToString().ToLower() + "&"); 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()); }