FeatureLinks in custom SharePoint pages
Wednesday, February 11, 2009, 22:57 -
SharePointPosted by Administrator
You can implement customactions in your own custom SharePoint page. This enables you to create your peage and afterwards,change or edit the links from within a feature.
Example:
A) In MyCustomPage.aspx <SharePoint:FeatureLinks runat="server"
ID="GeneralLinks"
Location="MyApplication.Settings"
GroupId="MySettings"
/> B) define in a feature this custom action: <CustomAction
GroupId="MySettings"
Location="MyApplication.Settings"
Sequence="1"
Title="My Item Settings"
Rights="ManageWeb">
<UrlAction Url="_layouts/MyCustomPage2.aspx?List={LISTID}
&MyitemID={MYITEMID}" />
</CustomAction> C: Parsing {STRING}As you can see there are 2 substrings that need to be parsed with the context. This is the place where
OnAddLink enters the scene.
This is wat reflector told me:
public event EventHandler<AddLinkEventArgs> AddLink;
In other terms when we change our FeatureLink like this:
<SharePoint:FeatureLinks runat="server"
ID="GeneralLinks"
Location="MyApplication.Settings"
GroupId="MySettings"
OnAddLink="OnAddMySettingsLink" />
/> and in the code behind we create our eventhandler:
protected void OnAddGeneralLink(Object sender, AddLinkEventArgs e)
{
e.Link.NavigateUrl =
e.Link.NavigateUrl.Replace("{MYITEMID}", m_id);
e.Link.NavigateUrl =
e.Link.NavigateUrl.Replace("{LISTID}", m_listID);
} e.link returns a
hyperlink webcontrol object that you can manipulate as you like.