2011-08-11 131 views
1

我使用Facebook的評論和喜歡的盒子,他們的工作,但像按鈕沒有工作。當我想添加sublayout我採取「錯誤發生」的消息。我查了日誌,異常消息是Facebook Like按鈕的Sitecore

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按鈕具有字體和我刪除了它,但我得到了同樣的錯誤。誰能幫我

它在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>"; 
+1

請發佈Like按鈕的代碼。它是在WebControl,Sublayout,XSLT還是直接在佈局中? –

回答

0

請問您的ASCX有Font屬性? Sitecore似乎試圖使用反射來設置該屬性的值,基於Font參數的存在。爲參數使用不同的名稱,或允許您的字體屬性可寫。

1

我從來沒有做過facebook集成,但是......我會在這裏給出一個猜測:

什麼是<fb:like>?這肯定不是一個有效的HTML標籤......看起來你正試圖在asp文字的內容中輸出一個服務器標籤,這是不行的。 ASP.NET只解析一次代碼...所以它不能實例化控件,除非它在ascx中明確定義。假設你在什麼地方定義爲控制,做這樣的事情在ASCX:

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

然後定義您的getParameter()的代碼隱藏方法。