Dec 30, 2011

SharePoint 2010 Modal Dialog


Hi Guys,

This is a small post regarding the Sharepoint Modal Dialog. In this post I am going to expalin you how to call a Sharepoint Modal Dialog from the applications. For this demo I have taken the Sharepoint Project template in visual studio and added an application page to my project. And then I placed a hyper link on this page to call the modal dialog.

The class SP.UI.ModalDialog represents the modal dialog and the method showModalDialog displays the modal dialog with the dialog options which we provide. 

Here is the code (written in C# .cs file) to show the modal dialog by registering a script which calls the modal dialog

 string myScript = @"   var mymodalDialog; 
                                 function ShowDialogTest(myViewUrl) { 
                                    var options = { 
                                        url: myViewUrl, 
                                        tite: 'Demo Page', 
                                        allowMaximize: true, 
                                        showClose: true, 
                                        width: 600, 
                                        height: 400 }; 
                                       mymodalDialog = SP.UI.ModalDialog.showModalDialog(options); 
                                }";
            ScriptManager.RegisterStartupScript(this, this.GetType(), ClientID, myScript, true);
            string strUrl = "http://moresharepoints.blogspot.com";
            hLinkshow.NavigateUrl = "javascript:ShowDialogTest('" + strUrl + "')";


This is the output on click of hyperlink

You can find more on this from msdn.



Dec 1, 2011

Enabling Inline Editing for Share Point lists

You can edit the data of sharepoint lists in line mode. But this is specific to the view of the sharepoint list. Here is the way how to enable the inline editing for the list

This is my announcements list.


Click on List Tab in the Ribbon-->Select Modify View Button




Go to Inline Editing Category (below of Filter Category)




Check Allow the Inline Editing option. Go to your list back you will find this feature like this

On mouse Over of your list item you will find the edit icon, Click On and do the changes


The same way you can add the items inline.

Note : This feature is specific to your view(Here All Items). You can set this using code too.


Nov 1, 2011

SPLongOperation Class in SharePoint

 Hi All,

Recently  I worked with this class in one of my projects to show the user with useful message when a long operation/activity is taking place in the background..I thought to share with you...

Here is the sample to use this..a webpart with a button. On click of button I am calling this..

protected void btnLoad_Click(object sender, EventArgs e)
{
  using (SPLongOperation myOperation = new SPLongOperation(this.Page))
  {
    //main bold text when action is in progress
    myOperation.LeadingHTML = "Hey..! Connection established to the database server"; 
    //small text when action is in progress
    myOperation.TrailingHTML = "Please wait during the data fetch"; 
    //start the operation
    myOperation.Begin();             
    //our long running action here
    System.Threading.Thread.Sleep(120000);//2 mins 
   //end of the operation and it redirects to home page after end of the operation
    myOperation.End("/sitepages/home.aspx");             
           
  }
}

Here is the result of this..




Happy Reading..!

SharePoint 2010 PowerShell Basics


Hi guys,

In this post I am going to explain you what is powershell management tool  in sharepoint , how it will be used and how it is different from the classic stsadm tool.

What is Sharepoint 2010 Management Shell :

In Sharepoint 2010 , a new feature called sharepoint 2010 management shell is included to work with the administrative jobs as we can do with the stsadm.exe in prior(moss).

Generally we can say powershell is a task automation tool which is built on top of the .net frame work. to achieve the administrative tasks .Here we write the  cmdlets(Command lets) , as command in the cmdprompt/stsadm. And also along with the cmdlets, the powershell can  execute the scripts,functions and executable programs too.  Here I will give a basic idea on the cmdlets..

Cmdlet ( called as command let )  : Its like a command to performs the task, takes the input and generally returns the .net frame work objects. The cmdlet is a combination of verb and noun in syntax.

Syntax  : The syntax is like Verb-Noun

Eg : Get-SPSite  

Start working with Powershell :  

Open the sharepoint powershell  console

StartàAll programsàMicrosoft Sharepoint 2010 ProductsàSharepoint 2010 Mangement Shell-->Right click on it and run as administrator




Execute the above mentioned command Get-SpSite.It gives all the site collections as below






There are many pre defined cmdlets introduced with the SharePoint 2010, you can find here. Here  I am giving the basic cmdlets to know

1.Get-Command : It will list all the cmdlets 

In above cmdlet if we specify the command it will give the entire syntax like this 

Ex : get-command  enable-spfeature

This gives you the entire syntax of the enable-spfeature cmdlets like this

Enable-SPFeature [-Identity] [-AssignmentCollection ] [-Confirm []] [-Force ] [-PassThru ] [-Url ] [-WhatIf []]

2.Get-Help  : It gives you the help topics:

Like if you know the part/word of the command and want to know the full cmdlets then you can use this like

Get-help *feature*

This will list all the commands which contains the word feature


3. Get-command  –verb   : will list all the cmdlets which has the verb

Eg :  get-Command  –verb , lists all the cmdlets which has the verb ‘enable’



4. Get-Command  -noun   : will lists all the cmdlets which has the noun

Ex:  get-Command –noun spsite,
 list all the cmdlets which has the spsite as noun






5. Get-help -examples

If you want any cmdlet with a example use this cmdlet

Eg : get-help enable-spfeature –examples


This will give the example of the cmdlet which enables the  feature in a given scope level (site/subsite) like this



The below are the cmdlets we use at the time of deployment

Adding the solution :
Add-SPSolution -LiteralPath  c:\purna\ Mywebpcm.wsp
Installing the solution :
Install-SPSolution -Identity Mywebpcm.wsp -GACDeployment
Updating the solution :
Update-SPSolution –Identity Mywebpcm.wsp –LiteralPath “C:\purna\ Mywebpcm_v2.wsp” –GacDeployment
Uninstalling the solution :
 Uninstall-SPSolution –Identity Mywebpcm.wsp –WebApplication http://pcmweb  
Removing the Solution :
Remove-SPSolution–Identity Mywebpcm.wsp
How cmdlets are different from the stsadm commands ?
1.  Cmdlets are based on the .net Frame work they are the instances of the .net framework classes. (Ex : when we get the error it throws a object based error instead a simple text as in stsadm)
2 . You can sort /format the result this was not possible with the stsadm.

Here are the more cmdlets from the msdn  article..

Happy reading..!

Aug 20, 2011

Missed Webparts Information while migration from Moss to SharePoint 2010

Hi,

In this post I am going to explain you how to get the missed webparts information after placing moss content database to SharePoint 2010 while upgrading process. This is a very useful information about the missed webparts when you are working with the migration process.


In Powershell when you run the Test-SPContenetDataBase cmdlet to check the readiness of the moss content database against the created 2010 site , you will get report with all missed setupfiles, missed webparts etc etc..there you will be provided with the ID of the webpart.The below query gives you the full information of the webpart such as the page where it resides, the status of the webpart like whether it is included in the page or not etc...

Here is the sql query to get more information of the webpart by providing its type id at highlighted place


Select SiteId, AllDocs.DirName as SiteUrl, AllDocs.LeafName as PageUrl, AllDocs.DirName + '/' + AllDocs.LeafName as Url, WebParts.tp_DisplayName as DisplayName, WebParts.tp_IsIncluded as Included,WebParts.tp_Deleted as Deleted FROM [dbo].[AllDocs] INNER JOIN [dbo].[WebParts] ON [AllDocs].Id = [WebParts].[tp_PageUrlID] Where [WebParts].[tp_WebPartTypeId] ='44c7b3b5-185f-c771-94fc-fcfdc52ceed5' Order By Url

The output will be like this




Happy reading..

Reference Link
http://sp2010extmigrareport.codeplex.com/

Aug 12, 2011

Meta Data Management Sharepoint 2010-Part1

Hi Guys

 In this post I am going to explain you a small concept of managing the meta data in sharepoint 2010. Here I will show a demo of the auto suggest option for a column using the metadata. In Sharepoint 2010 there is a lot of scope to managing the data/content when compared to moss.

The Sharepoint meta data hierarchy is organized in this way

• TermStore
• Group
• Termset and
• Term

To say In brief The Term Store contain Groups and the Groups contain Term Sets and the Term Sets conatin terms.The terms can also contain other terms.

Now I am creating the above mentioned by using the Term Store Management tool from Site Actions page ,follow the below steps
Go Site Actions—Site settingsàSelect Term Store Management under Site Administration section.
then

If you encounter this error, you need to create the Metadata service. If you already have check whether it is started or not.
Here I am going to create a new Managed Meta Data Service
Go to Central AdminàManage Service Applications under Application Management Section
Select Manage Service Applications


Then select New in Ribbonàthen select Managed Meta Data service.



Give a name (Here I am giving Managed Meta Data Service)
Specify the Database server; Select the New Application pool (which is recommended) on which this service will run. Give the name and specify the service account and then click ok.



Make sure that the Managed Meta Data Web service in start mode.
To check this
Central adminàManage services on server under system settings section and select the Managed meta data web service and start if it is stopped



Now Open the Termset
Select the Managed Meta Service and right click on that to create a group.


I have given name as Colors-Group.
Give the description and specify the group manager and contributor accounts

Here the group managers are the users who have contribute permission to add the users in to contributor group.
The contributors are the users, they can edit the termsests and terms in a group.
Now Create a Termset under this Group


Give Name as Color-Termset


Fill other information Description, owner, contact, stakeholders etc...See the description on left side to more information about these things and click Save.
Now create terms under this Termset

Give Red  and Fill other details in the right pane. Like this create more terms names.


So with this the Group, Termset and terms creation is over.  

How to use these Termsests in our Lists?
Here I am going to use this metadata for a column in my list.
I have a list called products with the columns Product name, Cost and Warranty. I am going to create a new column called ProductColor which will use this (the above created) metadata.
Go to List settings (or from ribbon) select create column
Give title as Product Color and select Type as Managed Metadata


See the continuation to this post Meta Data Management Sharepoint 2010-Part2

Meta Data Management Sharepoint 2010-Part2

In Colum settings You can choose multiple value field to allow multiple terms in to this column and In Display Format section you can select to display the label or the entire path of the term.
continuation to my previous post Meta Data Management Sharepoint 2010-Part1
And in Term Settings Section select the Color-Term set (which we created earlier) as shown below.


Give a Default Value if you need.
Now add an item in to the Products list


When you type ‘g’ it will give you the suggestions from the Color-TermSet like Gray , Green etc. This  field will not allow other values.

Here in this post I have created the terms in the site directly, instead we can import from a csv file or we can write the code to add the termsests.
And this is a small usage of metadata management, there are lot of features we can implement in sharepoint 2010 by managing the data.
Enjoy Reading..

Resources:
http://msdn.microsoft.com/en-us/library/ee559337.aspx
http://www.cmswire.com/cms/document-management/sharepoint-2010-using-taxonomy-metadata-to-improve-search-discovery-007425.php?pageNum=2
http://sharepointegg.blogspot.com/2010/10/creating-term-set-in-sharepoint-2010.html

Aug 10, 2011

TryGetList method in 2010 OM

 Hi

 Recently I noticed a method in 2010 object model. Generally when we writing the code to get a list from the web, we will get  the error if the list does not exist. For that we will loop through the lists collection and checks whether it exists or not



           SPSite oSite = SPContext.Current.Site;
            SPWeb oWeb = oSite.OpenWeb();
            SPList myList = oWeb.Lists["XYZ"];


If there is no list with the name XYZ, it throughs null reference exception. To avoid this,In 2010 OM a new method is introduced in the SPListCollection .Simply use this method instead of looping all the lists and check its existance


            SPList myList = oWeb.Lists.TryGetList("XYZ");
            if (myList != null)
            {
               //your operations
            }



Jul 4, 2011

Sharepoint webpart maintenance page

Hi Guys,

Some times while working with the Sharepoint pages ,we are unable to open/edit the page in the sharepoint designer if there is a problem with the webparts(generally script included webparts) . In such cases if we want to remove the issue caused webpart we will go for this webpart maintenance page.

This is a small way/trick to find the webparts on a page in sharepoint with their status.

If your page url is  http://myserver:5485/default.aspx

add ?contents=1 at the end of the url i.e http://myserver:5485/default.aspx?contents=1





From here you can find theat the webpart with name Demo2Tasks is on the page but it is in closed state.

Happy reading..!