5/31/2011

How to deploy webpart in Sharepoint 2010

Step by step procedure to install and deploy webpart in Sharepoint 2010

1. Goto Start -> All programs->Microsoft Sharepoint 2010 products - > Sharepoint 2010 Management Shell.
2. Type the following command for adding the solution

  PS C:\Users\Administrator> stssadm -o addsolution -filename D:\hellowroldWebpart.wsp
  Operation completed successfully.    

3.Type the following for deploying the solution

  PS C:\Users\Administrator> stsadm -o deploysolution -name helloworldWebpart.wsp -local -allowGacDeployment -force -url http://servername:40033/

4.Goto Start ->All programs ->Microsoft Sharepoint 2010 products --> Sharepoint 2010 Central Administration

5.Then goto Site actions -> site settings -> site collection features and active the deployed webpart in it.

Sharepoint 2010 Master Page Customization

Master page are files which provide structure and branding across Sharepoint site. To customize the master page follow these steps:

1.Open sharepoint designer and open the site
2.In the navigation pane click master page
3.Click master page and give a name

Sharepoint 2010 get logged in user name

string strCurrentUser = SPContext.Current.Web.CurrentUser.LoginName

SPContext:
Represents the context of Http request in Microsoft Sharepoint Foundation.
Use the SpContext class to return context information about objects as the 1)current web application 2)site collection 3)site 4)list or list items

Current:
Current Property provides properties that access various objects within the current SharPoint Foundation context,for example the current list,web site , site collection or Web application.

5/29/2011

Sharepoint Site.Openweb() method

returns the specified website from the site collection.

Overload List


  NameDescription
Public method OpenWeb() Returns the Web site that is associated with the URL that is used in an SPSite constructor.
Public method OpenWeb(Guid) Returns the Web site with the specified GUID.
Public method OpenWeb(String) Returns the Web site that is located at the specified server-relative or site-relative URL.
Public method OpenWeb(String, Boolean) Returns the Web site that is located at the specified server-relative or site-relative URL based on a Boolean value that specifies whether the exact URL must be supplied.

What is C Sharp Using statement

The Using statement in C# allows you to define the scope of an object lifetime, when the end of the using satament is reached  the object Dispose() will be called immediatly.

using (SqlConnection conn = new SqlConnection(connString))
{
     SqlCommand cmd = conn.CreateCommand();
     cmd.CommandText = "SELECT * FROM Customers";
     conn.Open();
     using (SqlDataReader dr = cmd.ExecuteReader()) {
          while (dr.Read())
          // Do Something...
     }
}

This is extremly useful when we need to release a resourece intensive object, like database connection object or a transaction scope                 
                                                                          read more

5/27/2011

Different ways of accessing list programatically

In SP 2010 you can programmatically access and code against list in a number of different ways using :

1. Server side Object Model
2. Client Side Object model
3. WCF Data Services
4. List Web Services
5. Customn WCF Services
6. Custom ASP.Net services

Sharepoint 2010 Lists

Overview of Sharepoint List:
A list is essentially a type of data structure in Sharepoint
The data in the list is refered to as list item
A list item comprises of field and field contains specific data.There are many types of list in sharepoint like Claendar list,Announcemnet list, custom list. Lists also include document libraries

Another more advanced type of Custom list is the External List . The external List dynamically loads data from external datasource into sharepoint list

The above diagram illustrates the conceptual structure of a list .

The Sharepoint List Object Model:

Exploring SharePoint Site in Visual Studio 2010

Start visual Studio 2010 Goto View --> Server Explorer.

Sharepoint 2010 designer adding javascript to pages

A simple way to add javascript code in Sharepoint pages in designer

1. Open the site in Sharepoint designer
2. Slect the desired pages from 'Site Pages' in designer
3. Goto Split or Code mode and add this below javascript code :-)

 4. You will get analert message when page loads !!

   

5/24/2011

Microsoft .Net Technologies

Sharepoint 2010 Connectable webparts



 This post describes how to create connectable webparts in Sharepoint 2010

A webpart that provides a string and another webpart that consumes and displays the value of the string.
These are the tasks to be followed :

1. Creating an interface to define the string that is being provided.
2. Creating a webpart from Visual Studio Webpart item template
3. Creating a provider webpart that defines a string
4. Creating a consumer webpart that uses and displays a string
5. Creating a webpart page and connecting the provider and consumer webpart.


A)  Creating an empty sharepoint project :

  1. Start Visual Studio 2010 in administrator mode.
  2. On the File menu, point to New, and then click Project. If Visual Studio is set to use Visual Basic development settings, on the File menu, click New Project.
  3. In the New Project dialog box, expand the SharePoint node under the language that you want to use, and then select the 2010 node.
  4. In the Templates pane, select Empty SharePoint Project.
  5. For the name of the project, type ConnectableWebParts, and then click OK.
  6. In the What local site do you want to use for debugging? drop-down list, select the local site that you want to use for debugging.
  7. Select Deploy as a farm solution, and then click Finish
 B) Creating an Interface : (what is an Interface?)
   
          public interface ITextBoxString
          {
             string TextBoxString { get; set;}
          }  


C) Creating a Provider Webpart
  1. In Solution Explorer, click the ConnectableWebParts project.
  2. On the Project menu, click Add New Item.
  3. In the Installed Templates pane, expand the SharePoint node, and then click 2010.
  4. Click Web Part, type StringProvider for the name of the Web Part, and then click Add.
  5. In the StringProvider.cs or StringProvider.vb code file, add the following code to indicate that the StringProvider class implements the ITextBoxString interface.
  public class StringProvider :Webpart, ITextBoxString
  
   6. Add the following code to create a text box, string and a button
 
     private TextBox myTextBox;
     private String _textBoxString = String.Empty;
     private Button myButton;

   7.  Implement the get and set method of the ItextBoxstring interface by adding the following code:
  

 
  [Personalizable()]
public string TextBoxString
{ get
    {
        return _textBoxString;
    }
    set
    {
        _textBoxString = value;
    }
}

                                               (what is personlisation)

  8. CreateChildControls(): instantiates controls and adds new control to the webpart
   
protected override void CreateChildControls()
{
    Controls.Clear();
    myTextBox = new TextBox();
    Controls.Add(myTextBox);

    myButton = new Button();
    myButton.Text = "Change Text";
    Controls.Add(myButton);
    myButton.Click += new EventHandler(myButton_Click);
}

9. Code to handel Click event

protected override void CreateChildControls()
{
    Controls.Clear();
    myTextBox = new TextBox();
    Controls.Add(myTextBox);

    myButton = new Button();
    myButton.Text = "Change Text";
    Controls.Add(myButton);
    myButton.Click += new EventHandler(myButton_Click);
}
10. Create a method to return tothe ITextBoxString object to share to other webpart.  Apply the ConnectionProviderAttribute attribute to identify the callback method that acts as the provider in a Web Parts connection.


[ConnectionProvider("Provider for String From TextBox", "TextBoxStringProvider")]
public ITextBoxString TextBoxStringProvider()
{
    return this;
}


D) Creating a Consumer Webpart
  1. In Solution Explorer, click the ConnectableWebParts project.
  2. On the Project menu, click Add New Item.
  3. In the Installed Templates pane, expand the SharePoint node, and then click 2010.
  4. Click Web Part, type StringConsumer for the name of the interface, and then click Add.
  5. In the StringConsumer.cs or StringConsumer.vb code file, add the following code to create objects for an ITextBoxString provider and a text box.
private ITextBoxString _myProvider;
private Label myLabel;

protected override void OnPreRender(EventArgs e)
{
    EnsureChildControls();
    if (_myProvider != null)
    {
        myLabel.Text = _myProvider.TextBoxString;
    }
}
 
protected override void CreateChildControls()
{
    Controls.Clear();
    myLabel = new Label();
    myLabel.Text = "Default text";
    Controls.Add(myLabel);
}
 
 [ConnectionConsumer("String Consumer", "StringConsumer")]
public void TextBoxStringConsumer(ITextBoxString Provider)
{
    _myProvider = Provider;
} 

E) Connecting the Provider and Consumer Webpart


  1. In Solution Explorer, click the ConnectableWebParts project.
  2. On the Project menu, click Add New Item.
  3. In the Installed Templates pane, click Code.
  4. Click Interface.
  5. Type ITextBoxString for the name of the interface, and then click Add.
  6. In the ITextBoxString.cs or ITextBoxString.vb code file, mark or verify that the ITextBoxString class is public
                                                                                                                                          
read more

5/20/2011

SharePoint 2010 Object Model

Sharepoint Object Model is the way of accessing , creating, deleting the Sharepoint lists, documents libraries,features, meetings,subsites etc through the visual studio code.

There are nearly 50 namespaces that house the sharepoint  object model.Out of these 50 namespaces we are using only 16 namespaces, rest of the namespaces are reserved for microsoft internal use.

SharePoint Object Model is used for operations on following fields:
  • Document Library
  • Lists
  • Features
  • Meetings 
  • Sites
  • Solutions
  • User Profiles
  • Business Data Catalog

Sharepoint Object model Heirarchy:


Sharepoint 2010 ASP.net Windows blog: APS.net Dropdownlist OnSelectIndex Changed Event

Sharepoint 2010 ASP.net Windows blog: APS.net Dropdownlist OnSelectIndex Changed Event

5/19/2011

APS.net Dropdownlist OnSelectIndex Changed Event

The OnSelectedindexChanged event handler of ASp.net DropDownlist Control enables you to handel the click event of list items at server side that is raised at hte time when user clicks to select a list item of dropdownlist control  read more

What is Active Directory


  • Active Directory stores information about Network Components
  • It allows clients to find objects within the namespace.
  • The term namespace  refers to the area in which the network components are located
  • For example the table of content of a book forms a namespace in which chapters can be resolved to page numbers,
  • DNS is a namespace which resolves host name to IP address
  • Telephone book provides the namespace for resolving names to phone numbers .
  • Active directory provides a namespace for resolving the name of the network objects to objects themselves
  • Every thing that Active directory tracks is considered as an object
  • An object is any user,system,resource or services tracked in active directory
http://wiki.answers.com/Q/What_is_active_directory_and_how_is_it_used
                                                                                                                                                read more

How to force uninstall a program you cannot uninstall

  1. Click Start and choose Run in the menu (If you're using Windows Vista then press Win+R on your keyboard).
  2. Type regedit and hit Enter.
  3. On the left side is the registry settings tree, use it to go to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
  4. Inside that key you'll find a lot of keys that belong to different programs. Some are named after the program's name, others as a mix of numbers and letters that makes no sense. Look through each of them until you find one that has the key DisplayName (on the right) with your program's name in it.
  5. Notice the key UninstallString - this key points to the uninstall program, and the log file usually resides in the same folder as that program.
  6. If you delete the key in which you've found the DisplayName key with the value equal to your program's name, then your program won't appear on the Add/Remove programs list

5/18/2011

What is CAML

Collaborative Application Markuup Languae is the XML-based language that is used to build and customize web sites based on Sharepoint team Services

CAML can be used to do the following:
 Provide schema definition to the web site provisioning system about how the site looks and acts
 Define views and forms for data and page rendering or execution.
Pulling a value from a particular form

Why do we use CAML:
CAML allows you the ultimate flexibility and extensibility with your Web sites based on SharePoint Team Services from Microsoft. If you want to make a universal change to all the sites that you are creating within your company — for instance, you want to change the logo to match your own company logo, or you want to add an Employee ID field to your document libraries — you must use CAML to do it

Location of CAML:  ( read more )

CAML Query tool :
Collaborative Application Markup Language (CAML) is an XML-based language that developers can use to create custom views and query SharePoint lists. Because it can be difficult to write anything other than basic queries, many tools have been developed to simplify this task. Several of these tools allow developers to write CAML queries within a designer. This is similar to the way developers write SQL queries for many commonly used databases.
  
 download

 

5/12/2011

Sharepoint 2010 FAST Search

Sharepoint 2010 'FAST' Search:
  1. FAST search keywords
  2. FAST search Promotion and Depromotion
  3. FAST search Users Contexts


5/11/2011

Difference between Sharepoint Foundation and Sharepoint Server 2010

  • SharePoint foundation 2010 is free download and has less feature than Sharepoint Server 2010
  • SharePoint foundation 2010 is a subset of Sharepoint Server 2010 just like WSS is a subset of MOSS
  • Sharepoint Server 2010 adds collabration features to the Foundation.

5/10/2011

How to create Newsletter in Sharepoint 2010

Step by Step procedure to create Newsletter in SP2010:

Step 1: Create a subsite (a blank site)
Step 2: Create a page.
Step 3: Click on site pages under Library
  


Step 4: Click on page tab select Alert me -> Set an alert on this page. and set the alert options as shown below


Step 5 : You can opt 'Send a daily summary ' or 'Send a weekly Summary' as needed.



How to add a string value inside a registry in C#?

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Security.Permissions;
using Microsoft.Win32;
namespace Software_EditRegistry {

public partial class Form1 : Form
{

{
InitializeComponent();
}

{

public Form1()
private void button1_Click(object sender, EventArgs e)// Set String Value inide the registry.

}
}
}
Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers\", "C:\\Users\\XXX\\Desktop\\Source Code\\XXX.exe","WINXPSP2", RegistryValueKind.String);

read more : http://www.java2s.com/Tutorial/VB/0440__Windows/GetstringvaluefromRegistry.htm

5/09/2011

Sharepoint 2010 Architecture

What is Microsoft Sharepoint?

  1. Sharepoint started out as a Document holding tank.People used sharepoint to strore and exchange documents with their co-workers.
  2. Microsoft Sharepoint is a popular web application platform developed by Microsoft for small to large organization.
  3. It is typically associated with web content management system and document management system.
  4. Applications of sharepoint: Sharepoint's multipurpose platform allows managing and provisioning of  intranet, extranets,websites,document management,social networking tools,enterprise search.. (the extranet is a portion of an organization's intranet that is made accessible to authorized outside users without full access to an entire organization's intranet)

5/03/2011

How to run windows program automaticaly when system starts up

1.Click windows icon
2.Type gpedit.msc in search box
3.Goto User Configuration > Windows Settings >Scripts(Logon/Logoff)
4. Double-Click Logon , add the logon script and press OK.

5/02/2011

What is Infopath?

Using Infopath you can :
1) Design form templates: design interactive and user friendly form templates.Form templates can be published to and accessed from a common location on c company network, such as shared folder, a web server.

2) Fill out fomrs: Infopath Offers spell check, allows users to merge data from multiple form to single form.allows to fill fom through browsers,mobile.

Infopath is based on Extensible Markup language (XML)

What is Target Audience in SharePoint 2010

By using Target Audience , you can display the content such as Lists, Libraries, Navigation links or Webparts to specific group of people.