Hello I want to get only date and month in pagelayout. I edin aspx file.

This is my code:

<div class="event-date">
    <%@ SPContext.Current.ListItem["SODigitalPageDate"] != null? (new DateTime(SPContext.Current.ListItem["SODigitalPageDate"].toString()).ToString("s") %>

This is following error error:

/_catalogs/masterpage/NewsPageLayout.aspx. The server block is not well formed.

I checked this question here

1 Answer 1


So take a look at my answer in the question you link to:

You are using


to open the code block, the answer uses


You are also missing the : string.Empty part in the end of the line


<%= SPContext.Current.ListItem["SODigitalPageDate"] != null ? (new DateTime(SPContext.Current.ListItem["SODigitalPageDate"].ToString()).ToString("s") : string.Empty %>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.