Hi,
I am displaying the document name in an ad-hoc layout like this
But the document is of type custom page type which has a field called "Title" and instead of documentName I want to display the title from that custom field?
I only want to display the title if the title is populated. how do I do this?
Hi Jai,
You can do something like this:
<%= string.IsNullOrWhiteSpace(CurrentDocument.GetValue("Title")) ? CurrentDocument.DocumentName : CurrentDocument.GetValue("Title") %>
I would rather recommend switching from ASCX layout to HTML layout and use macros. Uing the code blocks <%...%>, displaying expressions may lead to errors - the may depend on the page and control life cycle so it may get broken if you add or reorder web parts or controls on the page. This approach is also obsolete (used in ASP.Net 1.1) and not a best practice.... Another option would be adding e.g. a static text web part to the template and use the macro in it to get the desired value.
Please, sign in to be able to submit a new answer.