Developer forum

Forum » Templates » PageTemplateExtender to use with "IF Statements"

PageTemplateExtender to use with "IF Statements"

George Nelzo Pereira
Reply

Hi,

I have one PageTemplateExtender with some Tags... this tags are printing normally. If I use in one template (DataList) is printing but if I use the "IF Statements" to check is not working... But If I use the "IF Statements" in Master template than is working.

I'm using like this ways...

template.SetTag("Hupx.PM.SubProjectManager", (SubProjectManager == user.ID ? "True" : "False"));
PageView.TemplatePage.SetTemplateValue("Hupx.PM.ProjectManager", (ProjectManager == user.ID ? "True" : "False"));


Replies

 
Nicolai Pedersen
Reply

I do not understand the question.

Could you show some more code and the template bits...?

 
George Nelzo Pereira
Reply

Hi, let me try explain more...

I have one PageTemplateExtender, where I make some testes and give tags with value "True" or "False"...
https://georgenelzo.tinytake.com/sf/MTU0MTc0OV81MzM0NTYy

When I try show (print) this tags to inside of templates... is OK... Is showing dosen't matter if I'm using in Master Template or in templates (like using intern in one Data List).
But If I'm try to check with "IF Statements" than is work just inside of Master File template... inside of one Data List Template (with the same code used in master), is not checking... just printing...

I'm mean I can Print but cannot use IF Statements to check this value...

 
Nicolai Pedersen
Reply

A page template extender only has the tag available in page templates (and therefore master templates). When using html based templates, there is a 'bug' so that the tag works in module templates - but you cannot use conditionals as they are handled by the template where the tag belongs. If you switched to Razor templates, the tag would not be there at all...

So if you need to use conditionals, you need to extend the datalist template or make the tag global.

BR Nicolai

 

You must be logged in to post in the forum