Sitecore 的 Facebook Like 按钮

发布于 2024-11-28 23:05:35 字数 2917 浏览 0 评论 0原文

我使用 Facebook 评论和点赞框,它们可以工作,但点赞按钮不起作用。当我想添加子布局时,我收到“发生错误”消息。我检查了日志,异常消息是

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.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)

喜欢按钮有字体,我删除了它,但我得到了同样的错误。谁能帮我

它在子布局中,子布局

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 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.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>";

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

°如果伤别离去 2024-12-05 23:05:35

我从来没有做过 facebook 集成,但是...我会在这里猜测:

什么是 ?这肯定不是一个有效的 HTML 标签...看来您正在尝试在 asp Literal 的内容中输出服务器标签,这是行不通的。 ASP.NET 只解析代码一次...因此它无法实例化控件,除非它在 ​​ascx 中显式定义。假设您已在某处定义为控件,请在 ascx 中执行类似以下操作:

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

然后在代码隐藏中定义 GetParameter() 方法。

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.

把人绕傻吧 2024-12-05 23:05:35

你的 ascx 有 Font 属性吗? Sitecore 似乎正在尝试根据 Font 参数的存在,使用反射来设置该属性的值。为参数使用不同的名称,或者允许字体属性可写。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文