I've created a user control in a SharePoint 2013 farm solution, and added it to the AdditionalPageHead
control.
<Control Id="AdditionalPageHead" Sequence="90" ControlSrc="~/_ControlTemplates/15/Countdown/CountdownControl.ascx" />
The one and only thing I added to the .ascx file is a label control:
<asp:Label ID="Label1" runat="server" Text="Label">Calculating...</asp:Label>
In the .ascx.cs file I decorated the assembly and class with the MdsCompliant
attribute:
[assembly: Microsoft.SharePoint.WebControls.MdsCompliantAttribute(IsCompliant = true)]
namespace Countdown.ControlTemplates.Countdown
{
[Microsoft.SharePoint.WebControls.MdsCompliant(true)]
public partial class CountdownControl : UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
DateTime Christmas = new DateTime(DateTime.Today.Year, 12, 25, 0, 0, 1);
if (DateTime.Now.CompareTo(Christmas) > 0) Christmas = Christmas.AddYears(1);
int daysLeft = (Christmas - DateTime.Now).Days;
Label1.Text = "Only " + daysLeft.ToString() + " more " + (daysLeft == 1 ? "day" : "days") + " until Christmas!";
}
}
}
When I activate this simple example on a team site it works...sort of. It adds a line at the top of the page of course, but pages in a team site now failover (reloads the entire page without the /start.aspx#
). Deactivate the feature, and MDS starts working again.
As you can see, there's no JavaScript or stylesheet for me to register with SPPageContentManager
, so I don't think the answer to this other MDS question applies here.
Showing the days left until Christmas isn't the real requirement, it just makes a good example. What else do I need to do to keep MDS happy with a custom user control?