Tuesday, December 20, 2011

What are the types of ASP.NET projects?

You can create different types of ASP.net projects in Visual Studio 2010 , they are :
  1. Web Sites 
  2. Web Applications
  3. Web Services
  4. AJAX  Server

What is Visual Web Developer and its Features?

Visual Web Developer is a full-featured development environment for creating ASP.NET Web applications
It offers the following features:
  •  Web Page Design
  •  Page Design Features
  •  Code Editing
  •  Testing and Debugging (A local Web Server for testing and a debugger that helps you find errors in programs)
  •  Deployment (Tools to automate typical task for deploying a Web applications to a hosting server or a hosting provider)
 
Testing and Debugging
  •  Visual Web Developer provides an ideal environment in which to build Web sites and the npublish them to a hosting site.
  •  Visual Web Developer includes a local Web server that provides all the features you need to test and debug ASP.NET Web pages,without requiring IIS to be installed
  •  Finally, you can take the advantage of the built-in suppoert for the File Transfer Protocol(FTP), using the Visual Web Developer , you can connect directly to the host computer and then create and edit files on the server

Introduction to ASP.NET 4.0

  • ASP.NET is a Web Platform that provides all the services that we require to build server-based Web applications.
  • ASP.NET is built upon .NET Framework, so all .NET features are available to ASP.NET applications.
  • ASP.NET applications can be written in any language that is compatible with the CLR , including Visual Basic and C#
  • To create ASP.NET Web applications , we can use Visual Studio.
  • The tools and options in Visual Studio that are designed for creating Web Applications are referred to as 'Visual Web Developer'.
                                     Learn ASP.net 4.0 from msdn : http://msdn.microsoft.com/en-us/library/dd566231.aspx

SharePoint 2010 export 2010 list items to execl

$Web = WebUrl 
$List = Web.Lists["ListName"] 
$Items = $List.Items 

$Items | Select Title | Export-Csv

SharePoint 2010 Powershell


 Get-Help
 Get-Command
 Get-Command -Noun SP* (you get nothing because sharepoint module is not loaded)
 Get-PSSNapin -registered
 Add-PSSnapin Microsoft.Sharepoint.Powershell(to load sharepoint snapin)
 Get-Command -Noun SP* (now you get all powershell SP commands)
 Get-SPServiceApplication
 Get-SPFarm
 Get-SPWebAppliction
 Get-SPSite
 Get-SPFeature (get all features across farm/web application/sites)

SharePoint 2010 Security model


  • Understanding SharePoint security model requires understanding the difference between 'Authentication process and Authorization process'
  • Authentication is the mechanism by which systems securely identify the user attempting to access a resource 
  • Authorization is the mechanism by which a system determines the level of access the authenticated user 

  • SharePoint itself does not perform any authentication.
  • The authentication process is handled by an underlying authentication system, For example windows authentication is handled by Windows Server and IIS.
  • SharePoint only performs authorization to secured sources contained in sites,lists,libraries...
  • SharePoint 2010 offers two different authentication mode : Classic authentication mode and Claims-based authentication mode
  Classic mode Authentication:
  •  It refers to the integrated windows authentication
  •  You cannot configure the form based application if your web application is using Classic mode authentication 
  •  You can convert a web application from Classic mode authentication to Claims-based by only using  Powershell Command and it an irreversible process
Claims-based Authentication:
  •  SharePoint 2010 is built upon Windows Identity Foundation 
  •  It enables authentication from as well as non-windows based system.
  •  This also provides the capability to have multiple authentication in a single URL
  •  Claim-based authentication is built upon Windows Identity Framework 

Monday, December 12, 2011

How to give user permission for a web application

It is easy to add a user to a site collection of a web application, but what if we want to add a user to 100s of site collection of a we application?, in such cases we give the control to Central administrator who can do these steps:

Step1 : Go to Central administration
Step2 : Go to Application Management
Step3 : Go to Mange Web application
Step4: Select the Web application from the list
Step5: Click 'User Policy' shown on the ribbon
Step6: Do 'Add User' -> select user zone Click Finish

Resource Throttling in SharePoint 2010 Server

Throttle means setting up limit.
Throttling provides the option of monitoring and throttling the server resource and large list for web applications.
This enables you to control resource utilization during the peak usage and prevent user from negativity effecting the server performance

Resource throttling can monitor resources like CPU,Memory.
During the period of active throttling HTTP GET request and search robots will generate a 503 error

Friday, November 18, 2011

Why do we need LINQ?

LINQ: Language Integrated Query.

Queries are the one which retrieve data from a data source, SQL can be a data source or XML can be another data source.
SQL is the query type used to retrieve database data type from a database source.
Xquery is another type to retrieve xml data from xml data source.

So we developers have to learn different query types for each data formats,LINQ simplifies this situation by offering a consistent model for working with data across various kind of data format and data source.

In LINQ query you will be always working with 'Objects'. You use the same basic coding pattern to query data from XML,SQL,ADO.net ,.net collections etc..
                                                                                                                                       read more

Aware of SharePoint Site Columns?

Do you know SharePoint has some ready-made powerful columns , which many of then are not aware of it,
I was surprised to see these columns in sharepoint which really fulfilled my needs, and  these are all reusable

here you go! :


Monday, November 7, 2011

SharePoint 2010 UI enhancements

SharePoint 2010 shipped with lot of UI enhancement they are:
  • Ribbon Toolbar
           Now SP 2010 has UI as like in other Microsoft products, with ribbon interface it is easy to work in SharePoint sites,document library,lists,calendar,and other items
  • AJAX enabled
          Most of the activities in SP 2010 are AJAX enabled, Inserting /Editing or deleting items in List or Document library actions are available in place and require no full page request.
  • Bread Crumbs
      Shows links in tree view structure and makes navigation much easier.
  • Developer dashboard
      Developer dashboard is for the developers to diagnose  and monitor page, it displays various database calls, webpart execution time, authenticates user, critical errors and various SP request object calls.
  • Pop-up dialog boxes
       In SharePoint 2007 whenever you do any activity like creating new list etc. it directs to new windows and we have to come back to the main list after its completion, to overcome page traversals , SP 2010 pops up a dialog instead of redirecting to new page 




Monday, October 3, 2011

What is asmx file

.asmx is Web service file, which stands for Active Server Method file.

Wednesday, September 28, 2011

SharePoint list to InfoPath dropdown control


How to add SharePoint column values to InfoPath dropdown control

Step 1: Tools -> Data connections
Step 2: Add a new data connection to receive data

Step 3: Select from where do you want to receive your data
             Select SharePoint Library or List   

 Step 4: Provide SharePoint site address


 Step 5: Select the list which from which you want to receive the data


 Step 6: Select the fields which are needed from the list


 Step 7:  You can store the copy of data in the form of template If needed


Step 8:Give a name for your data connection


Step 9: Select the column which you need in the drop down box

In you SharePoint site! :






Friday, September 23, 2011

.Net Interoperability


  • .Net framework supports interoperability.
  • Interoperability is the ability of two systems to communicate with each other, The first system could be built on .Net framework and the other system can be of some other technology.


.Net Interoperability is of two types:

  •  Managed code interoperability
  •  Unmanaged code interoperability

Manged code interoperability:
 Create a class library in c sharp, which has a method called Hello()



 Call the c sharp class library in VB project.



Sunday, September 18, 2011

Application of CSharp timer

We can user timers to periodically to check the server and the system is up and running

Thursday, September 15, 2011

Reflection example

Reflection is a feature in .Net which enables us to get some information about the object in runtime.That information contains data of the class.also it gets the name of the methods inside the class and constructor of the objects.
read more

Difference between Array and Array List


  • An array can contain only one data type, while array list can contain any data type in the form of object.
  • With array you cannot dynamically increase or decrease the size of the array, but array list automatically increases the size, when any element or object is added.

Wednesday, September 14, 2011

Complete list of OOP terms

When to use Interface and Abstract Class

  • Interface members cannot have a definition
  • All interface members should be implemented by the derived class
  • An abstract class can have an instance field in it. The derived classes can assess this field through the  base syntax. This is the key difference between abstract and interfaces.

Abstract class can contain non abstract method. 
When we want that all subclass must implement all methods of
base class ;In such situation use interface.In other hand
when we want only some method of base class in our subclass
then use base class as abstract class because abstract class
can contain non-abstract method.

Interfaces are used when we want classes should follow the 
rules strictly. Rules like naming coventions e.g. if in
customer class one developer add method AddCustomer other
developer while implementing Invoice class could write
method name InvoiceAdd and also could change the Signiture
rules. for addition of customer we have at client code as
Cutomer.AddCustomer(A,B,C); and Invoice.InvoiceAdd(A,B)
To maintain uniformality if we declare interface and define
method Add(A,B) in that interface and implement that
interface in both the classes then the code will be uniform
all over the classes where ever we have implemented
interface and also all concrete classes must contain
methods which are defined in the interfaces.



Interface:

–> If your child classes should all implement a certain
group of methods/functionalities but each of the child
classes is free to provide its own implementation then use
interfaces.

For e.g. if you are implementing a class hierarchy for
vehicles implement an interface called Vehicle which has
properties like Colour MaxSpeed etc. and methods like
Drive(). All child classes like Car Scooter AirPlane
SolarCar etc. should derive from this base interface but
provide a seperate implementation of the methods and
properties exposed by Vehicle.

–> If you want your child classes to implement multiple
unrelated functionalities in short multiple inheritance use
interfaces.

For e.g. if you are implementing a class called SpaceShip
that has to have functionalities from a Vehicle as well as
that from a UFO then make both Vehicle and UFO as interfaces
and then create a class SpaceShip that implements both
Vehicle and UFO .

Abstract Classes

–> When you have a requirement where your base class should
provide default implementation of certain methods whereas
other methods should be open to being overridden by child
classes use abstract classes.

For e.g. again take the example of the Vehicle class above.
If we want all classes deriving from Vehicle to implement
the Drive() method in a fixed way whereas the other methods
can be overridden by child classes. In such a scenario we
implement the Vehicle class as an abstract class with an
implementation of Drive while leave the other methods /
properties as abstract so they could be overridden by child
classes.

–> The purpose of an abstract class is to provide a common
definition of a base class that multiple derived classes can
share.

For example a class library may define an abstract class
that is used as a parameter to many of its functions and
require programmers using that library to provide their own
implementation of the class by creating a derived class.
Use an abstract class

* When creating a class library which will be widely
distributed or reused—especially to clients, use an abstract
class in preference to an interface; because, it simplifies
versioning. This is the practice used by the Microsoft team
which developed the Base Class Library. ( COM was designed
around interfaces.)

* Use an abstract class to define a common base class
for a family of types.

* Use an abstract class to provide default behavior.

* Subclass only a base class in a hierarchy to which the
class logically belongs.


Use an interface

* When creating a standalone project which can be
changed at will, use an interface in preference to an
abstract class; because, it offers more design flexibility.

* Use interfaces to introduce polymorphic behavior
without subclassing and to model multiple
inheritance—allowing a specific type to support numerous
behaviors.

* Use an interface to design a polymorphic hierarchy for
value types.

* Use an interface when an immutable contract is really
intended.

* A well-designed interface defines a very specific
range of functionality. Split up interfaces that contain
unrelated functionality.




Monday, September 12, 2011

When to use Interface

If the requirement is like that something in your design changes frequently then go for interfaces instead of classes .


                                                                                                                                                                              read more

Sharepoint integration with MS Office

Friday, September 2, 2011

C# Constants

  • Constants are immutable values which are known at the compile time.

  • They do not change for the life of the program

  • C# built in types may be declared as constants

  • User-defined types including Classes, structs , arrays cannot be 'const'

  • C # does not support const methods,properties or events

  • When a complier encounters a const identifier in c# source code, it substitutes the literal value into the intermediate language(IL) code the produces 

  • Because there is no variable address associated with a constant at run time.

  • Constant fields cannot be passed by reference 

  • Constants are marked by public,private,protected,internal.                                                                      

                                                                                                                                                    read more

What are the types of C# members

Types of C# members:


  • Fields

  • Constants

  • Properties

  • Methods

  • Constructors

  • Destructors

  • Events

  • Indexers

  • Operators

  • Nested Types



Friday, August 26, 2011

Why to use DLL

A DLL is a collection of small programs, which can be called when needed by a larger program that is running in the computer. The small program that lets the larger communicate with a specific device such as printer or scanner is often packged as a a DLL program.

The advantages of DLL:
DLL's don't get loaded in RAM together with the program , so space is saved in RAM(Random Access Memory).

When and if a DLL file is needed, then it is loaded and run. For example, as long as a user of Microsoft Word is editing a document, the printer DLL file does not need to be loaded into RAM. If the user decides to print the document, then the Word application causes the printer DLL file to be loaded and run.

Wednesday, August 24, 2011

Why do we need Try-Finally block


The output that the code in the finally block will be executed after throwing the exception. However, the last statements in the program that followed the finally block will not be executed. This means that the exception
prevents control from being transferred to any part of the program except the finally block.



using System;
public class MyClass
{
static void Main()

{
string myString = "Finally";
object myObject = myString;
try
{
// The following conversion is invalid.
// It throws an exception.
int myInt = (int)myObject;
}
finally
{
// The code in this block is always executed:
Console.WriteLine("The program continues and ends here:");
Console.WriteLine("My String is: {0}", myString);
}
// The following code will not be executed:
Console.WriteLine("Hello again!");
}
}

It is also used for cleaning up the resource, like to close the open file stream..

Tuesday, August 9, 2011

How to Create Windows Services

What are Windows Services


  • Windows Service is a long running executable that perform specif function.

  • They do not require user intervention.

  • Windows services can be configured to start when the operating system is booted and run in the background as long as windows is running , or can be started/stopped manually when required.

  • Windows services can be developed using Microsoft visual studio.

  • Services can execute even when the user is not logged in.

Sunday, July 31, 2011

How to create an Assembly in .Net

I will show here how to create a simple dll in .net using visual studio 2010, and to link it with other exe.
This may help a .net newbie like me.

Step 1: Create a class library



Step 2: Create a Console application





Step 3: Link the dynamic library

Use add() and sub() methods


Step 4:  Build and Run the project






read more 

Thursday, July 28, 2011

Learn Microsoft's PowerShell

Nice tutorial on Power shell: read

Why do we need PowerShell:

 Traditionally, an Administrator would launch the GUI, select the service, and then either stop or start it. Doesn't seem like a big deal until you are asked to stop a service on multiple computers. Through PowerShell Scripting you will be able to start, stop, and change status types of a service on multiple computers without much effort. Write a script, run-it, and then kick you feet up on the desk.



Sunday, July 3, 2011

Sharepoint 2010 using client object model to write into List

For accessing Sharepoint list we need two types of Classes:

1. Client Context Class
     Web property
     List property
          Get by title

2. ListItemCreationinformation Class


Step by Step procedure to access sharepoint list

Step 1 : Create a new WPF project


Step 2 :
  Create  a WPF application as show below:
 

Step 3 : Downlaod these sharepoint related dlls and place it in 14 hive folder of your machine  , in which sharepoint server is not installed.
  

 Step 4 : Embed this Code :

      

Friday, July 1, 2011

How to move your heavy attached files in a mail to your peronal website

Embed this VBA Macro in your Outlook :
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
 Dim totalSize As Double 'to store total size of the attachments
 Dim FileName As String  'path for the temp folder
 Dim strBody As String
 Dim strUname As String
 Dim i As Integer
 totalSize = 0
 strBody = "The attached files are placed in the below location" & vbCrLf
 i = 1
 strUname = Environ("USERNAME")
 If Item.Attachments.Count <> 0 Then 'Check if files are attached
   For Each At In Item.Attachments
       totalSize = totalSize + At.Size
   Next At
 'Check the total size of attached files are greater than 1MB
 If totalSize >= 10 Then
   For Each Atmt In Item.Attachments
      strBody = strBody & "http://mysite/personal/" & strUname & "/Personal%20Documents/" & Atmt & vbCrLf
      FileName = "C:\Users\" & strUname & "\AppData\Local\Temp\" & Trim(Atmt.FileName)
      Atmt.SaveAsFile FileName 'Save the attachments to Temp folder of your system
      UploadFile "C:\Users\" & strUname & "\AppData\Local\Temp\" & Atmt, "http://mysite/personal/" & strUname, "Personal Documents/" & Atmt.FileName, "Test title", "Test checkin comment"
   Next Atmt
 End If
  
   For i = 1 To Item.Attachments.Count 'Delete Attached files in mail
    Item.Attachments(1).Delete
   Next i
  
    Item.Body = Item.Body & strBody
    'MsgBox ("Total Size:" & totalSize & "KB")
    MsgBox "Done"
  
End If
 
 End Sub

Function StringToByteArray(str)
  Set stream = CreateObject("ADODB.Stream")
  stream.Open
  stream.Type = 2 ''adTypeText
  stream.Charset = "ascii"
  stream.WriteText str
  stream.Position = 0
  stream.Type = 1 ''adTypeBinary
  StringToByteArray = stream.Read()
  stream.Close
End Function

Sub UploadFile(sourcePath, siteUrl, docName, title, checkincomment)
strHeader = "method=put+document%3a12.0.4518.1016" + "&service_name=%2f" + "&document=[document_name=" + docName + ";meta_info=[vti_title%3bSW%7c" + title + "]]" + "&put_option=overwrite,createdir,migrationsemantics" + "&comment=" + "&keep%5fchecked%5fout=false" + vbLf
byteArray = StringToByteArray(strHeader)
Set stream = CreateObject("ADODB.Stream")
stream.Open
stream.Type = 1 ''adTypeBinary
stream.Write byteArray
Set stream2 = CreateObject("ADODB.Stream")
stream2.Open
stream2.Type = 1 ''adTypeBinary
stream2.LoadFromFile sourcePath
stream2.CopyTo stream, -1
stream.Position = 0
Set xmlHttp = CreateObject("MSXML2.XMLHTTP")
xmlHttp.Open "POST", siteUrl + "/_vti_bin/_vti_aut/author.dll", False
xmlHttp.setRequestHeader "Content-Type", "application/x-vermeer-urlencoded"
xmlHttp.setRequestHeader "X-Vermeer-Content-Type", "application/x-vermeer-urlencoded"
xmlHttp.setRequestHeader "User-Agent", "FrontPage"
xmlHttp.Send stream
 If xmlHttp.Status = 200 Then
 If InStr(xmlHttp.responseText, "successfully") = 0 Then
  MsgBox "ERROR:" & vbCrLf & xmlHttp.responseText
  Else
  ''Checkin
  strHeader = "method=checkin+document%3a12.0.4518.1016" + "&service_name=%2f" + "&document_name=" & docName + "&comment=" + checkincomment + "&keep%5fchecked%5fout=false" + vbLf
  Set xmlHttp = CreateObject("MSXML2.XMLHTTP")
  xmlHttp.Open "POST", siteUrl + "/_vti_bin/_vti_aut/author.dll", False
  xmlHttp.setRequestHeader "Content-Type", "application/x-vermeer-urlencoded"
  xmlHttp.setRequestHeader "X-Vermeer-Content-Type", "application/x-vermeer-urlencoded"
  xmlHttp.setRequestHeader "User-Agent", "FrontPage"
  xmlHttp.Send strHeader
  End If
  End If
  If xmlHttp.Status / 100 <> 2 Then
   MsgBox "ERROR: status = " & xmlHttp.Status & vbCrLf & xmlHttp.responseText
   End If
End Sub
Function UserNameWindows() As String
Dim UserName As String
UserName = Environ("USERNAME")
'return UserName
End Function










 

Monday, June 27, 2011

Sharepoint 2010 Client Object Model

1. Why do we need Client Object Model ? /  Why Client Object Model evolved ?
    
        Microsoft was constantly getting request from customers for more webservices. to make it easier to get data from outside of sharepoint (for example : to show sharepoint data on your desktop, by consuming a webservices), So there are two options: 1) Request microsoft to produce more web serivices or 2) Create your own custom web services, Instead creating more and more web services over and over agin in each release,  Microsoft  came up with a different approach , they created someting called 'Client Object Model'.
 
2.Client Object Model comes in three flavours:

a. .NET web services
b. ECMAScript(javascript)
c. Silverlight

      

3.Where SP Client Object Model can be used to get data :

 a.Site Collections and Sites
 b.Lists,List Items,Views, and List Schemas
 c.Files and Folders
 d.Web,List, and List Item Propert bags
 e.Web parts
 f. Security
 g.Content Types
 h.Site Templates and Site Collection Operation


SharePoint 2010 allows using its Object model to run against a server running SharePoint. For clients (not running SharePoint in the box), the simplest way to communicate with SharePoint server is web services. SharePoint Client Object Model (OM) can be run on client PC (where SharePoint is not installed) to communicate with SharePoint server. So whereas SharePoint (Server) Object Model runs in a SharePoint server and can manipulate SharePoint objects, client OM can run in client PC and communicate with SharePoint server remotely.



Video : http://msdn.microsoft.com/en-us/SP2010DevTrainingCourse_OverviewoftheClientObjectModel 

Sharepoint 2010 Client Object Model 2010

Thursday, June 23, 2011

Sharepoint 2010 Workflows

1.What is a WorkFlow?
  •   Workflow is a series of action that corresponds to a work process, such as creating remedy request, making purchase orders.
  •   Sharepoint 2010 helps to automate these workflows , thereby increasing the productivity and efficiency of the organization.
2.What are the type of workflows that can be designed in SP 2010?
  •  List workflows
  •  Reusable List workflows
  •  Site Workflows
3.What are Reusable List workflows and Site Workflow?

   Resuable Workflows: We can create reusable list workflow in the top-level site in  the site collection and that workflow can be made globally reusable - meaning the workflow can be associated to any list, library or content type in the site collection. We can create reusable workflow in any subsite in the site collection and this workflow will be available for reuse in that particular subsite.

Site Workflow: Site workflow is associated to a site - not to a list/library/content type

4.What is a Three State workflow:

    read : http://www.dotnetfunda.com/interview/exclusive/x1078-what-is-a-threestate-workflow-in-sharepoint-.aspx





Wednesday, June 15, 2011

Yotube Rss feeds

You tube offers its RSS feeds for your webiste/blog : http://googlesystem.blogspot.com/2008/01/youtube-feeds.html

How to embed youtube video to you site:

<iframe width="200" height="150" src="http://www.youtube.com/embed/filename" frameborder="0" allowfullscreen></iframe>

Monday, June 13, 2011

Sharepoint 2010 recycle bin

Recycle bin allows users to restore the objects that are deleted.Microsoft sharpoint server 2010 supports two stages of recycle bin:
a.The first stage recycle bin 
b.Site collection - the second stage .

When recycle bins are enabled then users can restore items,documents etc.


When a user does this The item is The item can be restored by
Deletes an itemHeld in the first-stage Recycle Bin until the item is deleted from the Recycle Bin or the item has been in the Recycle Bin longer than the time limit configured for an item to be held in the Recycle Bin.Users or site collection administrators
Deletes an item from the Recycle   BinHeld in the second-stage Recycle BinSite collection administrators



First Stage Recycle bin: The first stage recycle bin is located at site level and it is available to users who have Contribute, Design or Full Control permission on a site.When a user deletes an item from a Web site, the item is sent to the site's first-stage Recycle Bin. Items located in the first-stage Recycle Bin count toward the site quota.Items remain in one of the first-stage Recycle Bins in the site until a specified time period has been reached (the default setting is 30 days).

Second Stage Recycle Bin: The second stage site collection is located at site collection administrator level.
Items remain in the second-stage Recycle Bin until a specified time period has been reached (the default setting is 30 days) or until the second-stage Recycle Bin reaches its size limit, at which time the oldest items are deleted. The time limit for the Recycle Bins applies to the total time after the item was initially deleted — not the time spent in either Recycle Bin stage.                                           
                                                                                                                                                  read more

Wednesday, June 8, 2011

Table-less Web desing

The power of  css float.... (CLICK ON THE IMAGE FOR FULL VIEW)

1) position:static - divs lying one below other


2) position:absolute - positioned from co-ordinates of the browser

3)position:relative; postioned to its adjacent divs.

1) without 'float':

2) with float: there you get it !!!


Tabel-less Web desing

coming soon.......

CSS positioning

Tuesday, June 7, 2011

SharePoint Farm

Sharepoint Farm can be defined as collection of one or more Sharepoint server and SQL servers.

but when do we need  a farm? . Small orgnization with limited people, and independent of location doesn't need a farm , they can use Single server system.

SharePoint 2010 developer dashboard

The developer dashboard is an instrumentation framework.Developer Dahsboard contains an extensible mechanism for measuring various performance counters at various scopes.

The developer dashboard records and displays the performance statistics of the code that executed to produce the current page .

Developer Dashboard contains an extensible mechanism for measuring various performance counters at various scopes. Within Developer Dashboard, the following performance counters are used to monitor usage and resource consumption at each stage of the requests.

Per-threaded Counters:
These counters measure values for the current request or timer job:
  • Thread execution time
  • Number, duration, call stack information and query text of each SQL Server query generated by the page
  • Number, duration, and call stack information of each WCF call
  • URL or timer job name
  • Current user
  • Execution start time
The Developer Dashboard can be displayed in the following modes:
  • On
    When enabled in On mode, the Dashboard is viewable on all pages that use the default master page.
  • OnDemand
    When the Developer Dashboard is set to OnDemand mode, an icon is displayed on the top right side of the page. This icon allows the user to toggle the Dashboard on and off.
Run this command in powershell:

PS C:\Users\Administrator > stsadm -o setproperty -pn developer-dashboard -pv on

                                                                                                        read more

Friday, June 3, 2011

Step by Step WCF example

Step by step procedure to create WCF:

A.Creating the service (Server side)

Step 1: Open Visual Studio 2010 and create project ,choose  "Windows Service  Application", and give a name to your project say MyService.

Step 2: Open IService.cs  , in that you can see [ServiceContract] where your intetface name is declared and [OperationContract] here you function contract should be defined here (note: delete the default functions if they are not needed), initialize you addData function here




Step 3: Open Service1.svc.cs and add the code for the addData function, ( note: delete the default functions if they are not needed)

                                  

Step 4: Declare your endpoint in web.config file add the below code which is in  bold and Italics.
                                 
                                   

Step 5:Save the project and run it

                                       
B. Creating the client to consume the service (Client side):

Step 1: Open another Visual studio 2010 , create a new ASP.net web application.right click the project and go to 'Add Service reference' ,copy and paste the service  url and press OK

Step 2: Open Default.aspx , create a simple button and lable controls

Step 3: Double click the button and add this following code

                                         

Ste 4: Build and run the project ,now your client has comsumed the services!!

                                          

read more

msdn :http://msdn.microsoft.com/en-us/library/ms734712.aspx 

Wednesday, June 1, 2011

Creating event receivers for sharepoint list

In sharepoint 2010 the following new event receivers have been added:

What are Sharepoint 2010 Event receivers?
  Event receivers are one of the power feature of sharepoint , the event receiver is in essence a managed-code assembly that is deployed to sharepoint and react to an event such as adding an item to the list,creating new list item..etc

For example , you might also want to log a transaction when a certain lists are updated, prevent the default error page and redirect to your own custom error page.



List Events:
List is being added, deleted

List Item Events:
List received a context event

Workflow:
Workflow in starting ,has started, completed,postended

List Email:
List received an email message

Web:
Site is being provisioned
Site was provisioned

Sharepoint service database tables

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

Tuesday, May 31, 2011

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.

Monday, May 30, 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

Friday, May 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 !!

   

Tuesday, May 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