Add today's date to the SharePoint homepage

Of course, there should be an easy way to put a simple code block in the main page :( I tried using the obvious syntax <%= "Hello, World!" %>, but the code blocks are not allowed. Then I tried the site column, I don’t know how to use them, and then I tried web zones, but the master page I tried to put the web part (which is more difficult to do and deploy btw) in the page layout, but it just does not display: /

All I want is something nice and simple at the top of my site that shows the current date and format that I want to use DateTime.Today.ToString("ddd, d MMMM yyyy"). How to do it?

(Otherwise, I resort to javascript document.write!)

Thanks everyone

+3
source share
3 answers

The recommended solution for this would be to use server-side control. As you say, developing a web part seems redundant for this. A simpler option would be to use a simple custom .ascx element and then link to it on the page. This post explains how to add a user control to the Templates folder and then link to it on the main page.

, , JavaScript . , . , , JavaScript SharePoint .

+6

" "?

, . , , SharePoint, ?

, web.conf:

<PageParserPaths> 
    <PageParserPath VirtualPath="/_catalogs/masterpage/*" CompilationMode="Always" AllowServerSideScript="true" IncludeSubFolders="true" /> 
</PageParserPaths>
+3

. , , . .

- ( ). -, . MasterPage, /, JavaScript:

var now = new Date();
document.write(now.format("ddd, d MMMM yyyy"));

, , , . , getTimezoneOffset() .

+1

Source: https://habr.com/ru/post/1738983/


All Articles