how to fetch componentPresentation from brokerdb?

198 Views Asked by At

I am new to SDL Tridion,just exploring content delivery. I used below code in the TBB of my pagetemplate

<% ComponentPresentationFactory factory = new ComponentPresentationFactory("tcm:0-6-    1");
ComponentPresentation ps = factory.GetComponentPresentationFactory("tcm:6-9841","tcm:6-9858-32");
if(ps!=null )
{
 string output="";
   output=ps.Content;
   Literal1.Text=output;
 }
 %>
  <asp:Literal id="Literal1"Text="" runat="server"<</asp:Literal>

I have published that component and used a dynamic component template. But no content is reflecting on the page.Did i missed something?

1

There are 1 best solutions below

2
Chris Summers On

Try removing the whitespace from the uri tcm:0-6-1 and your code should read factory.GetComponentPresentation("tcm:6-9841","tcm:6-9858-32");