..:: I like SharePoint ::.. Rotating Header Image

Template

SharePoint How to create ASPX Forms (#SPForms)

SharePoint offers a lot of options to create custom list forms like jQuery, SharePoint Designer, InfoPath (last Release) and of course ASPX forms. Regarding the last point i demonstrated a shorter “how to” at the Shareconf 2014 in Düsseldorf and would like to share the idea behind the ASPX Forms in this post.

The ASPX Forms (SPForms) which i mean are based on the use of the rendering templates along with ascx user controls.

AspxForms_6

The rendering template contains all elements which are needed by the listform. You can find the default rendering templates used by SharePoint in the 14 Hive or 15Hive in the controltemplate folder. It is the user control DefaultTemplates.ascx in which you’ll find the “Listform” template. Copy this one and add in your solution the mapped folder for controltemplates. In your user control add the copied template and rename the template id.



<sharepoint:renderingtemplate id="NewForm_Zaehlerstand" runat="server">
<template>
<span id='part1'><h3>Custom New Form</h3>
<sharepoint:informationbar ID="InformationBar1" runat="server"></sharepoint:informationbar>
<div id="listFormToolBarTop">
<wssuc:toolbar CssClass="ms-formtoolbar" id="toolBarTbltop" RightButtonSeparator="&amp;amp;amp;#160;" runat="server">
<template_rightbuttons>
<sharepoint:nextpagebutton ID="NextPageButton1" runat="server"></sharepoint:nextpagebutton>
<sharepoint:savebutton ID="SaveButton1" runat="server"></sharepoint:savebutton>
<sharepoint:gobackbutton ID="GoBackButton1" runat="server"></sharepoint:gobackbutton>
</template_rightbuttons>
</wssuc:toolbar>

</div>
<sharepoint:formtoolbar ID="FormToolBar1" runat="server"></sharepoint:formtoolbar>
<sharepoint:itemvalidationfailedmessage ID="ItemValidationFailedMessage1" runat="server"></sharepoint:itemvalidationfailedmessage>
<table class="ms-formtable" style="margin-top: 8px;" border="0" cellpadding="0" cellspacing="0" width="100%">
<sharepoint:changecontenttype ID="ChangeContentType1" runat="server"></sharepoint:changecontenttype>
<sharepoint:folderformfields ID="FolderFormFields1" runat="server"></sharepoint:folderformfields>

<sharepoint:listfielditerator ID="ListFieldIterator1" runat="server"></sharepoint:listfielditerator>

<sharepoint:approvalstatus ID="ApprovalStatus1" runat="server"></sharepoint:approvalstatus>
<sharepoint:formcomponent ID="FormComponent1" TemplateName="AttachmentRows" runat="server"></sharepoint:formcomponent>
</table>
<table cellpadding="0" cellspacing="0" width="100%"><tr><td class="ms-formline"><img src="/_layouts/images/blank.gif" width='1' height='1' alt="" /></td></tr></table>
<table cellpadding="0" cellspacing="0" width="100%" style="padding-top: 7px"><tr><td width="100%">
<sharepoint:itemhiddenversion ID="ItemHiddenVersion1" runat="server"></sharepoint:itemhiddenversion>
<sharepoint:parentinformationfield ID="ParentInformationField1" runat="server"></sharepoint:parentinformationfield>
<sharepoint:initcontenttype ID="InitContentType1" runat="server"></sharepoint:initcontenttype>
<wssuc:toolbar CssClass="ms-formtoolbar" id="toolBarTbl" RightButtonSeparator="&amp;amp;amp;#160;" runat="server">
<template_buttons>
<sharepoint:createdmodifiedinfo ID="CreatedModifiedInfo1" runat="server"></sharepoint:createdmodifiedinfo>
</template_buttons>
<template_rightbuttons>
<sharepoint:savebutton ID="SaveButton2" runat="server"></sharepoint:savebutton>
<sharepoint:gobackbutton ID="GoBackButton2" runat="server"></sharepoint:gobackbutton>
</template_rightbuttons>
</wssuc:toolbar>

</td></tr></table>
</span>
<sharepoint:attachmentupload ID="AttachmentUpload1" runat="server"></sharepoint:attachmentupload>
</template>
</sharepoint:renderingtemplate>


You also should add a register control of the “wssuc” which is needed:
<%@ Register TagPrefix="wssuc" TagName="ToolBar" src="~/_controltemplates/15/ToolBar.ascx" %>
(more…)

SharePoint list schema force checkout & checkin

If you creating a list definition and you want the list to force the user to checkin & checkout listitems, you can do this by adding this attribut ForceCheckout=”True”

You put it in the <List> tag at the beginning. It will say that it is not declared attribute, but it will work. Try it yourself.

 

..:: I LIKE SHAREPOINT ::..

SharePoint Create custom permission levels and groups with c#

You can use custom code to create your own permission level and custom groups in SharePoint. Usage is mostly a feature which user can activate or if you are using a site definition it would be used to provide custom groups and permission levels to a specific site template at creation time.

Let’s see what we have to do in code? This code could be implemented in a feature event receiver.

Create Permission Level

At first we create the permission level. There are two ways. You can use a default or a already existing permission level. In the second part you see how to generate your own permission level.



//Get default permission level
SPRoleDefinition roleDefAdmin = web.RoleDefinitions.GetByType(SPRoleType.Administrator);

//Create a new permission level
SPRoleDefinition roleDefContributeNoDelete = new SPRoleDefinition();
roleDefContributeNoDelete.Name = "Contributor Permissions without Delete";
roleDefContributeNoDelete.Description = "Mitwirken ohne Löschen";
roleDefContributeNoDelete.BasePermissions = SPBasePermissions.AddListItems | SPBasePermissions.EditListItems
| SPBasePermissions.ViewListItems | SPBasePermissions.OpenItems | SPBasePermissions.ViewVersions | SPBasePermissions.CreateAlerts
| SPBasePermissions.ViewFormPages | SPBasePermissions.ViewPages | SPBasePermissions.BrowseUserInfo
| SPBasePermissions.UseRemoteAPIs | SPBasePermissions.UseClientIntegration | SPBasePermissions.Open;

rootWeb.RoleDefinitions.Add(roleDefContributeNoDelete);


If you now deploy your permission level should be available.

Create Group and assign permission level

In these steps we create a group and assign the permission level to the group.



//create group
rootWeb.SiteGroups.Add("Meine Gruppe", site.Owner, site.Owner, "Beschreibung");
//get the created group from web
SPGroup groupAdmin = rootWeb.SiteGroups[groupname];
//Create a new assignment and afterwords, bind the group to it. Then set the roledefinition (permission level) to it and add it to the web.
SPRoleAssignment roleAssignAdmin = new SPRoleAssignment(groupAdmin);
roleAssignAdmin.RoleDefinitionBindings.Add(roleDefAdmin);
rootWeb.RoleAssignments.Add(roleAssignAdmin);
rootWeb.Update();


Now if you look at site actions – site permissions your group should be displayed with the permission level we assigned.

..:: I LIKE SHAREPOINT ::..

 

SharePoint 2010 How to hide the recycle bin and the all site content links

Sometimes you wish that your users or the users of your customer could not click or see the links like recycle bin and all site content.You can deactive the recycle bin or set permissions to not see the all site content, but what if that does not fit to the rest of your SharePoint Site? What if you do not want to deactivate it?

Well, it is not that difficult as you might expect.

Step 1: Add a Content Editor Webpart to your site

you can also add the css-stylesheet for the class in master page or your custom css file. But then it will hide the recycle bin and the link all site content on each page. So if you only want to hide these on a certain page it would not help to put it into the masterpage.

This css code changes / overwrites the original css file. After that you can hide the content editor webpart, so that the user won’t see your trick :) (more…)