Pages

Monday, November 5, 2012

Hide Top Level Menu and Ribbon Programmatically in SharePoint 2010


Introduction
In this article we will see how to hide a top level menu and ribbon programmatically in SharePoint 2010.
Steps: Let's assume that we have a site page with top-level navigation menus and Ribbon Controls.
Go to a site pages and add new page.
Add-New-Page-in-SharePoint.jpg
Once the page is created, if we click the page we are able to see the page with the top-level navigation menu with ribbon controls.
Top-level-navigation-menu-with-ribbon-control-in-SharePoint.jpg
Before we edit the site page, we need to save the following code in Shared Documents.
Code
<style type="text/css">
  #s4-leftpanel-content{        display:none;}   #s4-ribbonrow
{        display:none;}   #s4-titlerow{        display:none;}   #s4-workspace  {         overflow-yhidden !important;  }</style> 
We need to save this code in the shared documents as a text file as shown in the following:
document-as-text- file-in-SharePoint.jpg
Now we can start the edit pages.
Go to à Site Actions à Edit Page.
Edit-page-in-SharePoint.jpg
Edit-page-in-SharePoint(Image4)
Once we are in Edit Page Mode, just select the two columns layout this demo.
Text-Layout-option-in-sharePoint.jpg
Just click the second column and add a content editor web part:
contend-editor-in-SharePoint.jpg
editing-tool-in-SharePoint(Image7).jpg
Once it's added, click the Edit web part and select the above share document in the content link.
editing-tool-in-SharePoint.jpg
Content-editor-in-SharePoint.jpg
That's all our page will load with the following UI Changes:

page-in-SharePoint.jpg
We will see the content editor in our page that's not required to view in page content. We will again edit the content editor web part and set the "Chrome Type" to "None".
Content-editor-Option-in-SharePoint.jpg
Finally the page looks like the following image:
page-looks-in-Sharepoint.jpg
The preceding steps need to be followed for site pages, but if added for a web part page, we will see how easy it is to hide the Ribbon and navigation controls.
Site-page-in-SharePoint.jpg
Just create a web part page template, select the options which we want and create the page.
page-template-in-SharePoint.jpg
In the web part page, we have various options to inject our HTML code.  We can add "HTML Form Web Part" or using the "Content Editor Web part". We will see both options.
Select content "HTML Form Web Part". In the Edit web part mode just copy the above code in the Source Editor and save it.
HTML-Form-Web-Part-in-Sharepoint.jpg
HTML1-Form-Web-Part-in-Sharepoint.jpg
We will set the chrome type to "None" to hide in the UI.
Select-Hide-from-crome-type-in-sharepoint.jpg
We will see the output as shown in the following image, just added the default announcements list for demo.
announcements-in-sharepoint.jpg
Let's see how we can get the same result using the "Content Editor" web part. Go to the web part page edit mode, delete HTML form editor and add the using "Content Editor" web part.
delete-HTML-Form-editor-in-sharepoint.jpg

delete1-HTML-Form-editor-in-sharepoint.jpg
In the web part page, just click the "Click here to add new content" link and select HTML and Edit HTML Source option from the ribbon.

Edit HTML Source-In-sharepoint.jpg
Now we can add our code, save the changes and refresh the page and we will get the final output.

output-In-sharepoint.jpg
Summary
We have seen various options to hide a top level menu and ribbon programmatically in SharePoint 2010. If we add the same code in a Master Page using the SharePoint 2010 Designer, we will hide controls in the entire pages.

Tuesday, October 2, 2012

SharePoint 2013 UserProfile Properties Overview

Introduction

In this article we will see the SharePoint 2013 User Profile Properties and their uses in detail.

Step 1

Once we have configured and installed the SharePoint 2013, we will go to Central Administration (CA) as shown in the following URL:

installed-the-SharePoint2013.jpg

We will select the user profiles; see the list of configured profiles as similar to the SP 2010 pages.

Step 2

Now click the "Manage User Profiles" link, it will redirect to the profile search page.

Manage-User-Profiles.jpg

Step 3

Select the user name from the result; it will load the profile page.

Select-the-user-name.jpg

Step 4

We will see all the new properties that are available in a 2013 user profile compared to SharePoint 2010.

properties-sharepoint2013.jpg

We are able to follow #Tags and posts; these #tags will update automatically in our News Feed.

Tags-and-posts.jpg

We will get the preceding validation message, if we have not enabled the "Tag Service". There is a known issue in SharePoint 2013 online version.

http://office.microsoft.com/en-us/office365-suite-help/office-365-known-issues-HA102919011.aspx?CTT=5&origin=HA102919021#_SharePoint_Online 

There is some changes in Email Notifications properties compared to SP 2010 , because in news feed we have additional social features "like", "AtMention","Follow","Reply" options.

SharePoint 2010 Email Notification optionsSharePoint 2013-Email-Notification-options.jpg

SharePoint 2013 Email Notification optionsEmail-Notifications.jpg

Related follow option we have the following options in the user profile:

options-in-user-profile.jpg

We can control the data which flows to the News Feed, the system administrator will decide which activities will appear in this List.

flow-to-News-feed.jpg


SP 2013 has the option to set the Language preferences for individual users:

SP2013-options.jpg

We can see some of the other options available in a User Profile:

other-options-in User-Profile.jpg

Summary

The preceding properties are additional or new as compared to SharePoint 2010.

Saturday, September 1, 2012

SharePoint 2010 PowerShell access error


Introduction:
We got the below error while access the SharePoint 2010 powershell and will see the solutions.
Error: “the local form is not accessible. cmdlets with FeatureDependecyId are registered.”
Solution1:
SQL Server Management studio connect to the SQL Server instance where the farm config database is stored. In the Security section give the user the following rights on the config database: SharePoint_Shell_Access
Solution2:
Use the following Powershell cmdlet to give this user the correct databases permissions, since Direct database changes are not supported: Add-SPShellAdmin
Summary:
“Add-SPShellAdmin” will be more simple and powerful and we have different option to access level also

Working With Form Based Authentication in SharePoint 2010


Introduction
In this article we will see how to enable Form Based Authentication (FBA) in a SharePoint 2010 environment.

Step 1
Form Based Authentication (FBA) requires understanding the Membership provider. Please check the following link for more details. We have a dependency with SQL Server to handle the SQL Membership provider.

Step 2
We need to enable Claim Based Authentication at the Web Application level. By default SharePoint 2010 sets the Classic (windows) Authentication. It's better to create a new Web Application with this option.
authenticationinsharePoint.jpg
AuthenticationinSharePoint
Once we have enabled it, we can see the Claims Authentication Types options as in the following:
authenticationtypeinsharepoint.jpg
Just specify the Membership provider name (AspNetSqlMembershipProvider) and we'll use the same name in the Config key also. For the signin page, we'll use the default option, if required we will change it to a custom page. We didn't any other option to create the site collection.
signinPageinsharepoint.jpg
Step 3
Our assumption is that we already configured the SQL membership DB using the command "aspnet_regsql". Check the following links for reference.

Step 4
We need to add our SQL membership DB connection string in the Central Admin web.config file.
C:\inetpub\wwwroot\wss\VirtualDirectories Ã CA site Ã web.config

Step 5
We need to repeat Step4 of the config changes for the site collection which we just created with Claim Based Authentication.

Step 6
Repeat the Step4 config changes for the SecurityTokenService web.config file also.
IIS path - SharePoint Web Services Ã SecurityTokenService
C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\WebServices\Root Ã web.config
In addition to this change, add the following key in membership. Note that the key name "AspNetSqlMembershipProvider" will be the same name as used in the site collection creation.
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="LocalSqlServer" enablePasswordRetrieval="false" enablePasswordReset="true"requiresQuestionAndAnswer="true" applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5"minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10"passwordStrengthRegularExpression=""/>
Step 7
After the config key changes, we try to create a new site in the same site collection, we will see the following message and it ensures us that our configurations are correct.
webconfiginsharepoint.jpg
Assuming we already created profiles with the name "venkat1" and while creating the new site collection, in the secondary site collection administrator, we didn't use a people picker control, just type your profile name and press Ctl+k, it will resolve automatically and in the tooltip we saw the profile come from "AspNetSqlMembershipProvider".
tooltipinsharepoint.jpg
Just browse to the newly created site collection URL, we will see the following login page:

selectauthenticationinsharepoint.jpg

If we choose "Forms Authentication", it will prompt for a user name and password as shown below:

Signinwarninginsharepoint.jpg
If the User Name and password are authenticated, we will login our site.
authentication1insharepoint.jpg

Summary
Form Based Authentication is one of the alternate methods of Windows Authentication. Still we have limitations like the profile created using the "sqlmembershipprovider" needs to have some level of access in the site, in the above sample we added the user as secondary site collection administrator, so that user can login using FBA and view the site.

Asset Bundling For .NET Web Apps


Introduction

In this article we will see how to use the CASSETTE framework and its implementation in ASP.NET.

About CASSETTE

Cassette automatically sorts, concatenates, minifies, caches and versions all your JavaScript, CoffeeScript, CSS, LESS, Sass and HTML templates.

Step 1

Download the CASSETTE files from the following (or we can use the NUGET command to add the files to our project):

http://getcassette.net/download

Step 2

Once downloaded and the files referenced, it looks as in the following files:

Assetbundling.NETwebapps.jpg



We mainly used the "cassette" dll in this demo project and others are add by NUGET.

Step 3

Our package will add a configuration file as mentioned below in AppCode.

ConfigurationNETWebApps.jpg


Step 4

Add the required configuration details in that file, to control our CSS and JavaScript files.

ConfigurationdetailNETWebApps.jpg

We are not using any CSS files in the Demo project and we configured our scripts as the main/root folder for JavaScript.

Step 5

Add the script reference to the ASP.NET page, as a Casssette format; see:

ScriptReferenceASPNET.jpg


Add the RenderScripts() method for JavaScript load and RenderStyleSheet() method for CSS files; see:

RenderScriptmethodNETWebApps.jpg

Step 6

Run the page and you will see the result as in the following. To analyze the result we will add a simple ASP.NET and refer to the JavaScript.

ResultNETWebApps.jpg

We are able to see the JavaScript files, size and loading time.

JavaScriptNETWebApps.jpg

The preceding image is fiddler image for the same page, we will notice that every page refreshes and loads the scripts every time as a fresh request with the full file size.

Now let's see our actual implementation page result; see:
CassetteDemoPageNET.jpg

We will see the jQuery and prettyphoto files are loaded from the cache and its compressed. Let's see the fiddler image.
FiddlerImageNETWebApps.jpg
After the first time the scripts are loaded, it will load from the cache for any next page refresh.

CacheNETWebApps.jpg
In the fiddler, we won't find the script load for the subsequent page refreshes, because it's loading from the cache.

Summary

With a single change to Web.config,debug="false", Cassette switches into high-performance mode.

The CASSETTE bundle is flexible, extensible and optimized for developer happiness.

Asset Library Content Type Missing


Introduction

In this article we enable the SharePoint 2010 Asset Library Content Type. While attempting to create an Asset Library we are not able to find the "Asset Library" as shown below.

AstLBR1.jpg

If we check the site collection content type also, we are not able to find the "Asset Library" content types.

AstLBR2.jpg

Site collection -> Site Settings -> Site Content Types

Solution

Go the site collection feature link:

Site Collection Administration -> Features

Activate the following feature:

Once this feature is activated, we will have the following new content types in the site collection:

AstLBR3.jpg

Now we are able to see the "Asset Library" in the Create screen:

AstLBR4.jpg


Require.JS For Web Development: Part 2


Introduction

In this we will see some advanced features of Require JS and their implementation.

Config options

Let's start with various config options. We didn't used config file in the previous article.

What is in main.js?

A call to require() to load all the scripts you need and any initialization you want to do for the page. This example main.js script loads two plugins, jquery.alpha.js and jquery.beta.js (not the names of real plugins, just an example). The plugins should be in the same directory as require-jquery.js:

RqrJS1.jpg

Our config script will look like the preceding. Every parameter is optional and "baseUrl", "paths" are what we mainly used in this application.

Step 1

Add the script references as shown below in the Master page:

<script type="text/javascript" src="scripts/require.js"></script>
<script type="text/javascript" src="scripts/main.js"></script>
Now when we run the application we get the same results as in the previous article. Why do we want to use the Config option? Notice that we can shorten the JavaScript file names and control the script path also.

Now in the path section, we added two different versions of jQuery. Note that we didn't add the ".JS" file extension to the script names.
RqrJS2.jpg

In the Default page, we just added the following script. Two different versions of jQuery files will be handled in this script. One main advantage is that if we want to move to future versions of jQuery, we will simply change config file alone to upgrade the entire application.
RqrJS3.jpg

Shim

Shim is used to Configure the dependencies and exports for older, traditional "browser globals" scripts that do not use define() to declare the dependencies and set a module value. Example:

RqrJS4.jpg

In this code we mentioned that "PrettyPhoto" is dependent on the "jQuery-1.6.1" version and every time the "jQuery-1.6.1" version is loaded before the "PrettyPhoto" loaded. We will check the order of the script as below.

RqrJS5.jpg

Module

Asynchronous Module Definitions are designed to load modular code asynchronously in the browser and server. It is actually a fork of the Common.js specification. Many script loaders have built their implementations around AMD, since it as the future of modular JavaScript development.

The Asynchronous Module Definition API specifies a mechanism for defining modules such that the module and its dependencies can be asynchronously loaded. Please check the following URL for more details about module.

http://requirejs.org/docs/whyamd.html

Created a simple module as mentioned below, just return some string data. We will notice that this as anonymous function, we didn't mention any names.
RqrJS6.jpg

Define another module with the name "another-message".
RqrJS7.jpg

For easy understanding these modules are kept as a separate js file and in the Main.jS (wherever required) we can refer to the modules as shown below:
RqrJS8.jpg

In this code we are calling the anonymous function module, passing jQuery and the anonymous function as the parameter and obtaining the results as shown below.
RqrJS9.jpg

We will combine one more module called "another-message" and the module code will be placed in a separate file.
RqrJS10.jpg

The output will combine the results of both modules and will see the order of the modules also.

RqrJS11.jpg

Summary

Using "Require JS" we will write clean code and resolve the dependence via creating the modules.