If somebody like the post and its helpful in your work then, add comments.

Tuesday, February 22, 2011

SharePoint 2010 : Run Video on the SharePoint page ,web part or web server control

Being able to insert video into a SharePoint 2007 page is not as straightforward as you might think. Generally it’s accomplished by copying/pasting embed code in the content editor web part, or by finding a 3rd party solution that fits your needs.

Now you can plug a video right into a page OOTB. Silverlight controls are used to render the video in the browser. Another cool bonus here is that you can preview the video before inserting it.

When browsing your media with the asset picker, you can play the entire video to make sure you’re inserting the right one.

But when we need to play the video on any custom control or web part then the embed tag and other methods to run the video does not supported by the SharePoint 2010. Then how can show video on the SharePoint 2010? The simpler way is that when you add OOTB web part on the SharePoint, you see the source of the page and you can get the tag which is used by the Silverlight video web part. The tag is :

<object type="application/x-silverlight-2" data="data:application/x-silverlight-2," width="100%"  height="100%">
<param name="source" value="/_layouts/clientbin/mediaplayer.xap"/>
<param name="enableHtmlAccess" value="true"/>
<param name="windowless" value="true" />
<param name="background" value="#80808080" />
<param name="initParams" value="mediaSource=/SiteAssets/Search in SharePoint Server 2010.wmv,previewImageSource=/Style Library/Media Player/VideoPreview.png" />

<a href="http://go.microsoft.com/fwlink/?LinkID=124807" style="text-decoration: none;"><img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style: none"/></a><a href='/SiteAssets/Search%20in%20SharePoint%20Server%202010.wmv' class='media-link'></a>
</object>



There is two place you have to give the location of the video initParams and href. Second is the preview image of the video location in previewImageSource.



You can upload the video and image in the library and can show video on the web part or web server control or in the simple page layout. So, now its very easy to run video in our custom web part or control.



Enjoy SharePoint 2010 Smile

Tuesday, January 18, 2011

SharePoint : Get current Navigation using the Object Model

Use below method to get the Quick Launch information from the current web.

public static void QuickLaunch()
{
using (SPSite site = new SPSite(strSiteCollectionURl))
{
using (SPWeb web = site.OpenWeb()) //Can user SPContext.Current.Web
{
SPNavigationNodeCollection quickLaunchNodes = web.Navigation.QuickLaunch;

//Parent
foreach (SPNavigationNode node in quickLaunchNodes)
{
string strParentTitle = node.Title;
string strParentURL = node.Url.ToString();
Console.WriteLine("Parent : "+strParentTitle + " : " + strParentURL);
//Children
SPNavigationNodeCollection children = node.Children;
foreach (SPNavigationNode child in children)
{
string strTitle =child.Title;
string strURL = child.Url.ToString();
Console.WriteLine("Child : " + strTitle + " : " + strURL);
}
}

Console.ReadKey();
}
}
}

Sunday, December 19, 2010

Exchange Calendars Overlay in SharePoint 2010 Publishing Site

To activate the calendar overlay in the publishing site in sharepoint 2010. Just follow these below steps
  • Go to Site Settings
  • Go to Site Features
  • Activate the following feature "Team Collaboration Lists"
    TeamCollaborationList
  • Create Calendar type list
Now you can see the Calendar Overlay feature in the calendar list.
SchoolCalendar

Configuration of the Calendar Overlay Feature Follow below steps

  1. Click on calendar overlay in the Calendar view of the ribbon
    SNAG-0000
  2. Click on New Calendar Link
    SNAG-0001
  3. Enter the details and click OK
    SNAG-0003

After the above configuration, possibly you will get error like "Could not establish trust relationship for the SSL/TLS secure channel with authority"
Follow bellow steps
  • Go to "Central Administration" and click on "Security"
  • Under "General Security" click on "Manage trust"
  • Create a name (e.g. Name: Webmail)
  • Root certificate for the trust relationship:
  • Click OK
  • You need to specify the correct root cert for it to work

This will complete your configuration in the SharePoint Calendar Overlay.
Keep in mind that user should be in the domain of the Exchange and SP2010. Otherwise you will get this type of error "You should set Exchange e-mail address into your user profile to retrieve calendar data from Exchange server".

Enjoy SharePoint 2010 :)

Thursday, December 9, 2010

Content Query Web Part error “Unable to display this Web Part. To troubleshoot the problem, open this Web page in a Microsoft SharePoint Foundation-compatible HTML editor such as Microsoft SharePoint Designer. If the problem persists, contact your Web server administrator.”

Well this error occurs when you have not configured AAM (Alternet Access Mapping)for the particular web application. Suppose if the internal URL is http://server:81 and you are accessing the URL out of the server by mapping the DNS, then you will face this issue in the web part. SO, to resolve this issue just configure the public URL for the http://server:81 to like http://www.sample.com/.net etc.

Wednesday, December 1, 2010

STSADM on adding wsp Error “Object reference not set to an instance of an object. sample.wsp: The Solution installation failed. ”

Hi, Well today when I was deploying the SharePoint site I got the above error. Well on first look it seems that this is SPSite or SPWeb or we can say that this object model issue. But I got info from googling that this issue comes due to permission on the content db from which the user is deploying the WSP by using the STSADM command. Well I looking for more options for that but it seems that the issue is due to user permission on content db.

And guess it works. Well when you dont have permission on the Admin_content db then this issue will occur.

The below command will also help you check the permission

stsadm -o enumsites -url http://yoururl

Wednesday, October 6, 2010

SharePoint 2010: What is Sandbox Solution?

Well,

Many of the SharePoint are working on the SharePoint for a long time. Many of then also started working in the SharePoint 2010. Their are many things that SharePoint 2010 made easier then from SharePoint 2007/Moss. Many improvements are given to the SharePoint to that it can build a better solution.

If you have been reading about exciting new features of SharePoint 2010 you probably heard about something called SandBox Solutions.  What is the Sandbox solution?

SharePoint is a rich development platform with a large community actively developing solutions. The challenge, however, has always been the balance between creating solutions and deploying them in a way that you can trust will not damage or impair the SharePoint farm. Sandboxed solutions, new in SharePoint 2010, address this by allowing site collection administrators to deploy solutions that are safe to run. Sandboxed solutions are restricted to running under a subset of the SharePoint API and the framework can monitor these solutions and shut down any that risk the stability of the farm.

SandBox Solutions support the following SharePoint item types:

  • List definitions
  • List instances
  • Content Types/Fields
  • Navigation
  • Web Parts derived from WebPart
  • Event receivers
  • Custom Workflow Actions
  • Workflows

Development

For developing a sandbox solution you have to just create a new blank SharePoint Solution in Visual Studio 2010. Go to properties of the solution and change the solution type to true.

SanJuan013 

Deploying Sandboxed Solutions

The structure of a sandboxed solution is very similar to a farm solution, which generally runs with full-trust permissions. The main differences lie in how a sandboxed solution is deployed and in the process that hosts the solution (which determines whether a solution is a sandboxed solution or a farm solution). This means that the same sandboxed solution can run with full trust when it’s deployed at the farm level and with partial trust when it’s deployed at the site collection level.

SanJuan014

Monday, September 6, 2010

SharePoint 2010 : Paging in the SharePoint list

Hi,

Paging in the SharePoint 2010 list is done using the

SPListItemCollectionPosition 

The SPListItemCollectionPosition class supports paging through data sets, storing the state that is needed to get the next page of data for a specific view of a list.

ListItemCollectionPosition

Gets or sets an object that is used to obtain the next set of rows in a paged view of a list. The below code I have refined from the following link. It will return the given page like page 3, items say 4.



public static SPListItemCollection ExecuteCAMLToRetrieveListItemsInPages( string listName, string viewName, 
string caml, string[] columnNames, int pageIndex, int pageItemCount)
{
SPListItemCollection postDetailsItems = null;
using (SPSite Site = new SPSite(SPContext.Current.Site.Url))
{
using (SPWeb sharePointWeb = Site.AllWebs[XYZ])
{
// Check if the SharePoint web object is not null or not.
if (sharePointWeb == null)
{
}
// Get the Post List
SPList postList = sharePointWeb.Lists[listName];
// Get the SPLIst View
SPView listView = postList.Views[viewName];
SPQuery query = new SPQuery(listView);
query.Query = caml;
// Retrieve the items for the last page. E.g.: If request is for 5th page and item count/page=10 then row limit will retrieve
//40 items and 40th item will be used to get the column details which will be used for pagination.
query.RowLimit = (uint)(pageItemCount * (pageIndex - 1));
postDetailsItems = postList.GetItems(query);
// Get the previous page last item position. Use this item to retrieve the column details which will be used for pagination.
int previousPageLastItemPosition = postDetailsItems.Count - 1;
StringBuilder columnBuilder = new StringBuilder();
// Form the paging filter query string
if (columnNames != null)
{
foreach (string column in columnNames)
{
// Make sure that if the field value is mandatory and if you are passing it as NULL then SPList.GetItems will throw exception.
string columnValue =
(postDetailsItems[previousPageLastItemPosition][column] == null) ? string.Empty : postDetailsItems[previousPageLastItemPosition][column].ToString();
// Check if the value is null or empty
columnBuilder.Append("&p_" + column + "=" + columnValue);
}
}
query = new SPQuery(listView);
query.Query = caml;
// Create Paging Information which will be used for retrieving paging based items
SPListItemCollectionPosition objSPListColPos = new SPListItemCollectionPosition("Paged=TRUE" + columnBuilder.ToString());
query.RowLimit = uint.Parse(pageItemCount.ToString());
query.ListItemCollectionPosition = objSPListColPos;
// Execute the CAML query.
postDetailsItems = postList.GetItems(query);
}
} return postDetailsItems;
}

Wednesday, August 25, 2010

SharePoint Database when set to status ‘Suspect’

Hi,

Today my SharePoint 2010 Admin database automatically set to status Suspect.

SharePoint_AdminContent_c92d3a99-1800-4cac-b986-7e380ea42454(Suspect)

I search for that issue and I got the solution which is below

EXEC sp_resetstatus 'SharePoint_AdminContent_c92d3a99-1800-4cac-b986-7e380ea42454'

ALTER DATABASE [SharePoint_AdminContent_c92d3a99-1800-4cac-b986-7e380ea42454] SET EMERGENCY

DBCC checkdb('SharePoint_AdminContent_c92d3a99-1800-4cac-b986-7e380ea42454')

ALTER DATABASE [SharePoint_AdminContent_c92d3a99-1800-4cac-b986-7e380ea42454] SET SINGLE_USER WITH ROLLBACK IMMEDIATE

DBCC CheckDB ('SharePoint_AdminContent_c92d3a99-1800-4cac-b986-7e380ea42454', REPAIR_ALLOW_DATA_LOSS)

ALTER DATABASE [SharePoint_AdminContent_c92d3a99-1800-4cac-b986-7e380ea42454] SET MULTI_USER

Thursday, August 19, 2010

SharePoint Web Part Development

Hi again,

Now these days I am working for the SharePoint 2010 internet facing or public facing publishing site. No doubt's we are using the OOTB publishing features of the SharePoint 2010 publishing, content types, approval workflows etc.

Well, in that site I am developing the custom web parts for the site in the Visual Studio 2010 version 10.0.30319.1 RTMRel. In this or before VS 2010 we have the .net framework 3.0 in which HtmlGenericControl which is present in the System.Web.UI.HtmlControls namespace. It will help us to build the custom UI for the web part instead of maintaining HTML in the web part and render to output(HTMLTextWriter).

You can create any of the HTML tag from HtmlGenericControl this like div, table, table row, table column and that will be very easy to manage in the code.

How this will work ?

In the code we have to add reference for the control and declare the HtmlGenericControl control in the class like :

HtmlGenericControl divSponser_Blogs_Contatiner;
In the CreateChildControl or any method where you are creating the UI for the web part you can instantiate it.

divSponser_Blogs_Contatiner = new HtmlGenericControl("div");
You can also set its properties like CSS class or its attributes in the control after instantiate.

divSponser_Blogs_Contatiner.Attributes.Add("class", "Sponser-Blogs-Contatiner");

or like

divSponser_Blogs_Contatiner.Attributes.Add("id", "Sponser_Blogs_Contatiner");
if you wnat to create table from HtmlGenericControl then you have to just replace div with table.

divSponser_Blogs_Contatiner = new HtmlGenericControl("table");
Well this post will help you to create rich UI web parts for the SharePoint and it will also make easy to mage and create the custom web parts from the .net framework.

Friday, July 23, 2010

SharePoint 2010 : Custom Membership and Role providers

 

Hi all,

Now these day I was busy with some SharePoint 2010 project. One of my project I have to configure Form Based authentication for the site. In this configuration we didn't use the default Asp.Net providers for authentication.

“ASP.NET membership is designed to enable you to easily use a number of different membership providers for your ASP.NET applications. You can use the supplied membership providers that are included with the .NET Framework, or you can implement your own providers.”

So I have create or we can implemented the custom provider class with custom SQL database and tables. We have inherited the asp.net abstract classes “MembershipProvider” and “RoleProvider”  in our custom classes. The project is class library project for creating DLL, e have to used for installing in GAC.

This Membership Provider class have following following structure:

Variables

        private int newPasswordLength = 8;
        private string connectionString;
        private string applicationName;
        private bool enablePasswordReset;
        private bool enablePasswordRetrieval;
        private bool requiresQuestionAndAnswer;
        private bool requiresUniqueEmail;
        private int maxInvalidPasswordAttempts;  private int passwordAttemptWindow;
        private MembershipPasswordFormat passwordFormat;
        private int minRequiredNonAlphanumericCharacters;
        private int minRequiredPasswordLength;
        private string passwordStrengthRegularExpression;
        private MachineKeySection machineKey; //for encryption

Properties

VISIOITPro000

Method which I have implemented:

VISIOITPro002

And the methods which I have not Implemented:)

VISIOITPro001

Their are some other helper methods also there like encryption for password. Similarly I have implemented role providers. Well you can get both the classes from here.

Some more configuration you have to make for the SharePoint 2010 FBA like STS, Central Admin and your port 80(primary web app) application.  I have manually manipulated all web.config files of application and they are working.

Enjoy :)