Tuesday, March 30, 2010

Sharepoint Website Collection.

Listing all the websites from the share point site and its owner.

SPSite site = new SPSite("http://localhost");
SPWeb web=site.AllWebs;
foreach(SPWeb web in collection)

Listing all lists in the website
SPSite site = new SPSite("http://localhost/SiteDirectory/IT"); //IT-site name
SPWeb web = site.OpenWeb();
SPList list = web.Lists["Posts"]; // a List in the site
foreach(SPListItem col in list.Items)
DropDownList2.Items.Add(col.Title.ToString()); // Item in the List


SPWebCollection lets you to enumerate the Websites in the Share point server.

SPSite site = new SPSite("http://win-zmmypcbnz7k/");

SPWebCollection collection = site.AllWebs;
foreach (SPWeb web in collection)

Monday, March 15, 2010

Webservice String array value in C #

When we works with Webservice,we can't use the .NET data types like DataSet or DataTable,ArrayList as return value.
So we need to convert these into unified data type such as string or string array.

public string[] RecordAll()
SqlConnection con = new SqlConnection("Server=Your server\\SQLExpress;Database=SPTest; Trusted_Connection=Yes");
DataSet ds = new DataSet();
ArrayList al = new ArrayList();
SqlCommand cmd = new SqlCommand("Select * from Registers",con);
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
adapter.Fill(ds, "Registers");
foreach (DataRow row in ds.Tables[0].Rows)
string[] stringArray = (string[])al.ToArray(typeof(string));
return stringArray;


Saturday, March 13, 2010

Querying the XML file using LINQ

In this example i tried to find the available balance by passing the account number as parameter to the function through Linq

XDocument doc = XDocument.Load("C:\\Account.xml");
var result = from ds in doc.Descendants("Account")
where ds.Element("IDNumber").Value == account.ToString()
select new
Balance = ds.Element("AvailableBalance").Value,
AccountID = ds.Element("IDNumber").Value

return result.ToArray();

My accounts XML will be



Friday, March 12, 2010

How sharepoint functioning

Its my scribble for understanding clearly what i learned from googling.

When you install the WSS 3.0 or Microsoft Office Sharepoint server 2007,WSS configures the IIS server to forward all requests regardless of file[such as HTML,ASPX or other web supported files]and content types[ such as .doc,.docx,.xls,ppt or.pdf or video streaming files] using the "Virtual Path Provider component".

In traditional web application ASP.NET framework process the file system[.aspx] alone.But in WSS or MOSS handles this in different way using Virtual Path Provider.
All site details and file name will be stored in MS-SQL Database or Windows Internal Database.WSS or MOSS fetch these details from the SQL Database.
We can deal with the database using SPContentDatabase object from the Microsoft.Sharepoint namespace to manipulate.

When you create the site in WSS 3.0,all site details,file name,contents such as webparts and context [Admin or user] will be stored in SQL Database.When accessing this site WSS serves from the SQL DB.

Tuesday, March 09, 2010

UserControl events in ASP.NET

Usercontrol's events
It occurs when user ends transaction
It occurs when user completes transaction
It occurs when usercontrol binds to DataSource
When user control(Server controls) releases the memory.This is last stage of server control's life cycle.
It occurs when usercontrol initializes.This is the first step of server control's life cycle.
this event occurs where server control load into Page Object
occurs after the controls loaded but prior to rendering.
Occurs where server controls unloaded from the memory