Surely there must be a simple way of putting a simple code block into a master page :( I've tried using the obvious <%= "Hello, World!" %>
syntax but code blocks aren't allowed. Then tried a site column, but don't know how to use them. Then tried web zones but master pages can't use them. Tried putting a web part (which are super difficult to make and deploy btw) into the page layout, but it just doesn't render :/
All I want is something nice and simple at the top of my site which shows today's date and the format I want to use is DateTime.Today.ToString("ddd, d MMMM yyyy")
. How do I do it?
(Otherwise I'm resorting to javascript document.write!)
Thanks all,
The recommended solution to this would be to use a server-side control. As you say, developing a webpart for this seems like overkill. A simpler option would be to use a simple .ascx user control and then reference this on the page. This post explains how to add the user control to the Templates folder and then reference it in your master page.
Although for such a simple problem, I think your idea of JavaScript is actually ok. And it would allow you to show the current time in the user's timezone which wouldn't be as easy on the server-side. It does seem like a hack to use client-side code for this type of thing, but using JavaScript code in SharePoint is actually a really powerful tool.