SharePoint 2010: Create "Alert Me" button
Hopefully this is an easy one...
I need to create an "Alert Me" button on my custom SharePoint masterpage which when clicked, will direct the user to a pre-populated "New Alert" page for that particular site/list. The OOTB blog site template already features this exact same button at the bottom of the default.aspx page, it's markup is as follows:
http://server/currentsite/_layouts/SubNew.aspx?List={00000000-0000-0000-0000-000000000000}&Source=http://server/currentsite/default.aspx
Does anyone know if there is an OOTB control开发者_StackOverflow社区 or web part that I can just drop into my page layout to reproduce this?
Obviously I could create the button dynamically in the codebehind of my page layout if need be, but I'd be surprised if there isn't a pre-written control already.
Thanks in advance...
For those insterested, I ended up rolling my own usercontrol for this. Code is as follows:
HTML
<asp:HyperLink ID="AlertHyperLink" runat="server"><img alt="Alert me" src="/_layouts/images/menualert.gif" title="Alert me to any changes that get made to this site." /></asp:HyperLink>
C#
protected void Page_PreRender(object sender, EventArgs e)
{
// If the current page is not associated with a list, then hide the list-sensitive tools.
if (SPContext.Current.List != null)
{
this.AlertHyperLink.NavigateUrl = string.Format(
"{0}/_layouts/SubNew.aspx?List={{{1}}}&Source={2}",
SPContext.Current.Web.Url,
SPContext.Current.List.ID.ToString(),
this.Server.UrlEncode(this.Page.Request.Url.ToString()));
}
else
{
this.AlertHyperLink.Visible = false;
}
}
精彩评论