开发者

Facebook Like Button for Sitecore

I use facebook comments and like box,they work but like button doesn`t work. when i want to add sublayout i take "An error occured" message. I checked the logs, Exception message is

Exception: System.InvalidOperationException
Message: Attempt to write to read-only property: Font. Declaring type: System.Web.UI.WebControls.WebControl
Source: Sitecore.Kernel
   at Sitecore.Reflection.ReflectionUtil.SetProperty(Object obj, PropertyInfo property, Object value)
   at Sitecore.Reflection.ReflectionUtil.SetProperty(Object obj, String name, Object value)
   at Sitecore.Data.Items.RenderingItem.SetParameters(Object control, String parameters)
   at Sitecore.Data.Items.RenderingItem.GetControl(RenderingSettings settings, XmlNode controlNode)
   at Sitecore开发者_JAVA技巧.Layouts.RenderingReference.GetControl()
   at Sitecore.Nexus.Web.NexusPlaceholderApi.(Placeholder placeholder)
   at Sitecore.Nexus.Web.NexusPlaceholderApi.CreateChildControls(Placeholder placeholder)
   at System.Web.UI.Control.EnsureChildControls()
   at Sitecore.Layouts.PageContext.Expander.Expand(Control control)
   at Sitecore.Layouts.PageContext.Expander.Expand(Control control)
   at Sitecore.Web.UI.WebControls.Sublayout.CreateChildControls()
   at System.Web.UI.Control.EnsureChildControls()
   at Sitecore.Layouts.PageContext.Expander.Expand(Control control)
   at Sitecore.Nexus.Web.NexusPlaceholderApi.(Placeholder placeholder)
   at Sitecore.Nexus.Web.NexusPlaceholderApi.CreateChildControls(Placeholder placeholder)
   at System.Web.UI.Control.EnsureChildControls()
   at Sitecore.Layouts.PageContext.Expander.Expand(Control control)
   at Sitecore.Layouts.PageContext.Expander.Expand(Control control)
   at Sitecore.Layouts.PageContext.Expander.Expand(Control control)
   at Sitecore.Layouts.PageContext.Build()
   at (Object , Object[] )
   at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
   at Sitecore.Layouts.PageContext.BuildControlTree(Object sender, EventArgs e)
   at System.Web.UI.Page.PerformPreInit()
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Like button has a font and i deleted it but i got same error. Could anyone help me

Its in the sublayout,Sublayout

ascx side;

<div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>
<asp:Literal runat="server" ID="fbLikeButton"></asp:Literal>

ascx.cs side;

Sublayout slb = (Sublayout)this.Parent;
System.Collections.Specialized.NameValueCollection parameters = Sitecore.Web.WebUtil.ParseUrlParameters(slb.Parameters);
fbLikeButton.Text = "<fb:like href=\"";
fbLikeButton.Text += parameters["Url"];
fbLikeButton.Text += "\" send=\"true";
fbLikeButton.Text += "\" width=\"";
fbLikeButton.Text += parameters["Width"];
fbLikeButton.Text += "\" show_faces=\"true";
fbLikeButton.Text += "\" action=\"like";
//fbLikeButton.Text += "\" font=\"";
//fbLikeButton.Text += parameters["Font"];
fbLikeButton.Text += "\"></fb:like>";


I've never done facebook integration, but... I'll give a guess here:

What is <fb:like>? That's not a valid HTML tag for sure... It appears you are trying to ouput a server tag in the content of an asp Literal, which is not going to work. ASP.NET only parses the code once... so it can't instantiate an control unless it is explicitly defined in the ascx. Assuming you have defined somewhere as a control, do something like this in the ascx:

<fb:like runat="server" send="true" action="like" width=<%=GetParameter("Width")%> href=<%=GetParameter("Url")%>></fb:like>

Then define your GetParameter() method in the code-behind.


Does your ascx have a Font property? Sitecore appears to be trying to use reflection to set the value of that property, based on the presence of a Font parameter. Either use a different name for the parameter, or allow your font property to be writeable.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜