Tuesday, August 14, 2012

Webpart vs. Visual Webpart in SharePoint 2010


Using Visual Web Parts vs. Traditional Web Parts in SharePoint 2010

 Learn about the advantages of using Visual Web Parts and traditional Web Parts in SharePoint 

Read and Display SharePoint List Data in Gridview Control



I have developed a custom web part which reads data from SharePoint List and display in a GridView control by Visual Studio 2010.
In this scenario, I have a list name "Employee" with 4 collumns named Title, Birthday, Male, Position.

Add the following code to the .ascx file

ID="grid" runat="server" AutoGenerateColumns="false">
   
       
       
           
              
   

    
Add the following code to the .cs file:

protected void Page_Load(object sender, EventArgs e)
{
           
 SPWeb web = SPContext.Current.Web;
           
 SPList list = web.Lists["Employee"];
           
 SPListItemCollection items = list.Items;
            grid.DataSource = items.GetDataTable();
            grid.DataBind();
}

Add the web part to the Sharepoint page, we have the following result


Hope this helps!

Monday, August 13, 2012

Code input mask

jQuery Masked Input Demo
Phone Number: (123) 1234-5678
Mobile Number: (012) 123-4567
Date of Birth: 22/08/1986

Code for Input Mask

Today I’ve got a requirement to force the user input to follow this international phone number format “(country-code) 1234-568” & because I love jQuery I started to look for an input mask plugin, I found this one. So I built simple ASP.NET Web Application to start playing with it. It’s contains 3 TextBoxes/Input fields, first one for the landline phone number, second one for mobile phone number, & the third and last one for the date of birth. Here’s the aspx code snippet: jQuery Masked Input Demo
Phone Number: (123) 1234-5678
Mobile Number: (012) 123-4567
Date of Birth: 22/08/1986

Input mask in ASP.net

Today I’ve got a requirement to force the user input to follow this international phone number format “(country-code) 1234-568” & because I love jQuery I started to look for an input mask plugin, I found this one. So I built simple ASP.NET Web Application to start playing with it. It’s contains 3 TextBoxes/Input fields, first one for the landline phone number, second one for mobile phone number, & the third and last one for the date of birth. Here’s the aspx code snippet: jQuery Masked Input Demo
Phone Number: (123) 1234-5678
Mobile Number: (012) 123-4567
Date of Birth: 22/08/1986

SharePoint Connected Webpart