Tuesday, March 23, 2010

Telephone.com

Check Telephone.com our new website using .netframework 3.5

You can now add your own twist to telephone.com and personalize your messaging style by writing your own SMS applications to implement any feature you would like to add to your messaging experience using our wcf rest API http://www.telephone.com/devcorner.aspx

Regards

Tuesday, October 14, 2008

Move my blog

Hello, I'm going to be moving my blog to http://weblogs.asp.net
Please update your subscriptions


Regards

Tuesday, September 30, 2008

Rosario VS2010

Reveals extensive enhancements for simplified application life-cycle management, provides sneak peek at all key focus areas for Visual Studio 2010("Rosario") and the .NET Framework 4.0.


Stay tuned to http://channel9.msdn.com/VisualStudio/  for all of the action


Regards :)

Microsoft and JQuery

Microsoft will be shipping jQuery with Visual Studio going forward. jQuery will be distributed as JavaScript library as-is, and it will not be forking or changing the source from the main jQuery branch. The files will continue to use and ship under the existing jQuery MIT license.

Microsoft will also distribute intellisense-annotated versions that provide great Visual Studio intellisense and help-integration at design-time

The jQuery intellisense annotation support will be available as a free web-download in a few weeks (and will work great with VS 2008 SP1 and the free Visual Web Developer 2008 Express SP1).


For more info, check Scott's post

For more info about JQuery, click here


Regards

Tuesday, August 26, 2008

Friday, June 20, 2008

Bind a custom List to a DropDownList

using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using Microsoft.SharePoint;
using System.Configuration;
namespace TrackingClassLib.Sharepoint
{
public class Clients
{
public static DataTable GetClients()
{
DataTable dtClients;
using (SPSite site = new SPSite(ConfigurationManager.AppSettings["ClientListSiteName"].ToString()))
//Get the url of the site from web.config
{
using (SPWeb web = site.OpenWeb())
{
SPList clientsList = web.Lists["Clients"];
if (clientsList != null)
dtClients = clientsList.Items.GetDataTable();
else
dtClients = null;
return dtClients;
}
}
}
}
}
-------------------------------------------------------------------------------
private void LoadCompanies()
{
ddlCompany.DataSource = Clients.GetClients();
ddlCompany.DataTextField = "Title";
ddlCompany.DataValueField = "Id";
ddlCompany.DataBind();
}


Regards

Tuesday, April 22, 2008

Attaching Event to Custom List

I have a 2 custom Lists “Projects” and “Project Folders Type”
Projects have the following columns: Project Name, Project Description
Project Folders Type has the following columns: Title

I have a document library called “Project Details” with a column “Name”

Problem: The moment I add new project to Projects List, I need to create a folder with name of the projects and sub folders (from Project Folders Type List) in Project Details.

Solution: Create an Item Added event and attach it to Projects List


First:
Create a class Library, Add reference to Microsoft.Sharepoint.dll, and Inherit from SPEventItemReceiver


namespace EventRecieverDemo
{
public class DemoListEvents : SPItemEventReceiver
{
public override void ItemAdded(SPItemEventProperties properties)
{
string toolTipFieldInternalName = "";

using (SPWeb web = properties.OpenWeb())//Open the web you want to use
{
//Get a reference to the "Project Name" Column in "Projects" List
toolTipFieldInternalName = web.Lists[properties.ListId].Fields["Project Name"].InternalName;

//Get the projectTitle just Added
string projectTitle = properties.AfterProperties[toolTipFieldInternalName].ToString();

//Get the "Project Details" document Library where you want to add the folders
SPList myList = web.Lists["Project Details"];

//Create a folder in "Project Details" document library with the name of the project
SPFolderCollection projectFolder = web.GetFolder("Project Details").SubFolders;
projectFolder.Add(projectTitle);

//Get a refernce where you want to add subfolders
SPFolderCollection subfolders = web.GetFolder("Project Details/" + projectTitle).SubFolders;

//Get a reference to "Project Folders Type" where the names of the folders exist
SPList folderNames = web.Lists["Project Folders Type"];

//Loop through "Project Folders List"
foreach (SPListItem folderType in folderNames.Items)
{
//Add Sub Folders
subfolders.Add(folderType["Title"].ToString());
}
}
}
}
}

Build your solution and throw the dll in GAC (c:\windows\assembly), to get the publictoken key right click your dll in the GAC and hit properties

Second: Add another class to the class library and inherit from SPFeatureReceiver
namespace EventRecieverDemo
{
class FeatureReciever :SPFeatureReceiver
{
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
SPWeb web = properties.Feature.Parent as SPWeb;
try
{
SPList list = web.Lists["Projects"];
list.EventReceivers.Add(SPEventReceiverType.ItemAdded, "EventRecieverDemo, Version=1.0.0.0, Culture=neutral, PublicKeyToken=a1942c85f62a2b8d", "EventRecieverDemo.DemoListEvents");
list.Update();
}
finally
{
web.Dispose();
}
}
public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
{
SPWeb web = properties.Feature.Parent as SPWeb;
try
{
SPList list = web.Lists["Projects"];
list.EventReceivers[0].Delete();
list.Update();
}
finally
{
web.Dispose();
}

}
}
}
Build your solution again and throw the dll in GAC




Third:
Add an XML file to the class library named Feature.XML, click on the properties tab/Schemas and press ADD and browse to C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\XML and select wss.xsd, now you can have intellisense in your XML File


<?xml version="1.0" encoding="utf-8" ?>
<Feature xmlns="http://schemas.microsoft.com/sharepoint/"
Id="0491ECA8-2ED8-4e9c-B5CF-8E8FCDFFBF16"
Title="Projects Feature"
Description="Create Folders and sub folders for the project"
ReceiverAssembly="EventRecieverDemo, Version=1.0.0.0, Culture=neutral, PublicKeyToken=a1942c85f62a2b8d"
ReceiverClass="EventRecieverDemo.FeatureReciever"
Scope="Web"/>

The Id of the feature is GUID, you can get it from the Create GUID tool in visual studio

Forth:
Browse to “C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES” and create a folder “ProjectsFeature” and throw feature.XML inside it


Fifth:
Now we need to install the feature
Open command prompt and browse to:” C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN”
stsadm –o installfeature –name ProjectsFeature

Reset your IIS
Open you portal go to Site settings/Site Features and activate ProjectsFeature.

Test it :)