2010年11月17日 星期三

Show Menu on Blank aspx page

Remove from page:
<asp:Content ContentPlaceHolderId="PlaceHolderLeftNavBar" runat="server"></asp:Content>
<asp:Content ContentPlaceHolderId="PlaceHolderNavSpacer" runat="server"></asp:Content>

Find the "PlaceHolderPageImage" and add image:
<asp:Content ContentPlaceHolderId="PlaceHolderPageImage" runat="server"><IMG SRC="/_layouts/images/blank.gif" width=1 height=1 alt=""></asp:Content>

2010年11月12日 星期五

Get Url for Current page

To Ensure the page is reachable. User:
SPUtility.GetPageUrlPath(HttpContext.Current));

2010年11月11日 星期四

Save Multiple Users into SharePoint List

SPFieldUserValueCollection pmCollection = new SPFieldUserValueCollection();

for...{
SPUser user= SPContext.Current.Site.RootWeb.AllUsers[your username];
SPFieldUserValue UserName = new SPFieldUserValue(web, user.ID, user.ID.ToString());
pmCollection.Add(UserName);
}

SPContext.Current.ListItem[your field name] = pmCollection;

// save item
SaveButton.SaveItem(SPContext.Current, false, string.Empty);
SPContext.Current.ListItem.Update();

2010年11月8日 星期一

Create List Item Menu on Specific List

1. Goto "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES" and create a folder (Exampel: CustomListItemMenu )

2. Create “Feature.xml”


<?xml version="1.0" encoding="utf-8" ?>
<Feature xmlns="http://schemas.microsoft.com/sharepoint/"
Id="{C7B4AEEE-88D8-46eb-80AB-666228D19280}"
Scope="Web"
Title="Custom Action ***"
Version="1.0.0.0"
Description="Anything you can input">
<ElementManifests>
<ElementManifest Location="MenuItems.xml"/>
</ElementManifests>
</Feature>


3. Create “MenuItems.xml” which can be named anything else as long as you provide appropriate reference in “ElementManifest” section described above. Here is what we’ll have in our “MenuItems.xml”:

<?xml version="1.0" encoding="utf-8" ?>

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction
Id="Name of the action"
RegistrationType="ContentType"
ShowInLists = "True"
RegistrationId="0x010060E9BA54FF561C4E8F05788698ABF445"
Location="EditControlBlock"
Sequence="101"
Title="Open as Word 2003***"
>
<UrlAction Url="~site/_layouts/CustomAction.aspx?ID={ItemId}& amp;List={ListId}"/>

</CustomAction>

</Elements>

NOTE:
You need to find out
RegistrationType="ContentType" RegistrationId="0x010060E9BA54FF561C4E8F05788698ABF445"

1. Go Setting => List Settings => Advanced Settings
2. Select the Yes radio button on the “Allow management of content types”
3. Click OK
4. On the Setting page. Find the Content Type section and click on "item" or your default content type"
5. Copy the “ctype” value in URL as your RegistrationId
6. Copy this value into the RegistrationId attribute


If you want to do list type. Setting is:

RegistrationType="List"
RegistrationId="100"

RegistrationId = templateID
Go here to find out.



4. The key item in the definition above is to set the “RegistrationId” to the “ListTemplate” value we have taken down earlier. This will ensure the context menu item will be attached only to the types we have specified.

stsadm -o deactivatefeature -name CustomListItemMenu -url http://site -force
stsadm -o uninstallfeature -name CustomListItemMenu -force
stsadm -o execadmsvcjobs


stsadm.exe -o installfeature -name CustomListItemMenu
stsadm.exe -o activatefeature -name CustomListItemMenu -url http://site -force
stsadm -o execadmsvcjobs

iisreset