I'm using alternate templates to render the content other nodes by passing in the node ID.
string id = Request.QueryString["id"]; int nodeID; if (int.TryParse(id, out nodeID)) { DocumentTypes.NewsArticle newsArticle = ContentHelper.GetByNodeId<DocumentTypes.NewsArticle>(nodeID); this.CurrentContent = newsArticle; }
I thought I could set CurrentContent and use it in the template like any other but CurrentContent cannot be set.
Is there some other intelligent way to to do this?
Why wouldn't you just make a protected property in your alternate template's code behind class, initialize it with the retrieved NewsArticle instance and use that property the same way you would use the CurrentContent property?
Setting CurrentContent?
I'm using alternate templates to render the content other nodes by passing in the node ID.
I thought I could set CurrentContent and use it in the template like any other but CurrentContent cannot be set.
Is there some other intelligent way to to do this?
Regards,
Matt
Are you trying to render another news article on the page if a different id is passed in? Can you use RenderTemplate instead?
Stephen
Hey Matt,
Why wouldn't you just make a protected property in your alternate template's code behind class, initialize it with the retrieved NewsArticle instance and use that property the same way you would use the CurrentContent property?
Regards,
Sasa
Hi Sasa,
Yes I've considered RenderTemplate and I'm using it elsewhere but I've decided not to here.
I've decided to declare a property
and set that with
Then I can use it in my template like so
Regards,
Matt
Hi Matt,
Yes, that's exactly what I meant.
I would just suggest you mark the property as "protected" instead of "public".
Regards,
Sasa
Oh yes, thanks.
is working on a reply...