我使用Facebook评论和喜欢的盒子,他们工作,但像按钮不起作用。当我想添加sublayout我采取“发生错误”消息。我检查了日志,异常消息是
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)
喜欢按钮有一个字体,我删除它,但我有同样的错误。任何人都可以帮助我
它在子布局中,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>";
答案 0 :(得分:1)
我从来没有完成过脸书整合,但是......我会在这里猜一下:
什么是<fb:like>
?这肯定不是一个有效的HTML标签......看起来你正试图在asp Literal的内容中输出一个服务器标签,这是不可行的。 ASP.NET只解析一次代码...因此除非在ascx中明确定义,否则它无法实例化控件。假设您已将某个地方定义为控件,请在ascx中执行以下操作:
<fb:like runat="server" send="true" action="like" width=<%=GetParameter("Width")%> href=<%=GetParameter("Url")%>></fb:like>
然后在代码隐藏中定义你的GetParameter()方法。
答案 1 :(得分:0)
你的ascx有Font属性吗? Sitecore似乎试图使用反射来设置该属性的值,具体取决于Font参数的存在。为参数使用不同的名称,或允许您的font属性可写。