Thursday, June 25, 2009

Example for Internet facing MOSS site

Hi folks,
Here is a best example for internet facing MOSS site.
Its :)
Yup It has been recently developed with MOSS technologies by a consulting company Advaiya.
Envy those people who got the chance to work for the official site of Sharepoint ;) Lucky you...!

Resource : Nice article, it explains implementation of new features. Really inspiring.... Great job.


Sunday, June 14, 2009

MOSS: Free Master pages templates for SharePoint


You can download free Master page samples for SharePoint from Microsoft website.

Click to view the download page

The Link also has the instructions to setup.


Thursday, June 11, 2009

Thank God!

Application Seems to be Stable :)

Thanks to Almighty...

Monday, June 8, 2009

SQL Server Schedule Job : Unable to cast object of type

Hi Folks...

One of my pal, when he was trying to create SQL Server Job to call a SSIS he got the following error;

Unable to cast object of type 'Microsoft.SqlServer.Management.Smo.SimpleObjectKey' to type 'Microsoft.SqlServer.Management.Smo.Agent.JobObjectKey'. (Microsoft.SqlServer.Smo)

When we googled for the same it was mentioned in lot of forums that the it worked fine once we install SQL Server 2005 service pack 2 (SP 2)


Download: Microsoft SQL Server 2005 Service Pack 2

Fauzi ~ 4Z

MOSS: Code blocks are not allowed in this file


When you try to add a server side code for an aspx page in your document library with the help of share point designer. you might get the following error when you try to view the page.

An error occurred during the processing of /Pages/Yourfile.aspx. Code blocks are not allowed in this file.

The reason is that Sharepoint by default disables server side code (code behind) for an aspx page. The Solution is we need to add the path of the page as exception in web.config.



<PageParserPath VirtualPath="/pages/YourFile.aspx" CompilationMode="Always" AllowServerSideScript="true" />



Wednesday, June 3, 2009

Sample MOSS webpart & deployment

Hi Folks...

Seems people search for Sample MOSS webpart and land into my previous blog where i have written how to develop a webpart from your XP machine. So let us provide what people came looking for....

Following is a sample web part i created some time back which fetches data from database and displays in a table. The web part class should always inherit Webpart(System.Web.UI.WebControls.WebParts) as base class. For webparts we usually write the code to override any events like Render, RenderWebPart or RenderContent.
In the sample code i have overrided Render event which takes the parameter System.Web.UI.HtmlTextWriter object.

The Database operations i have used Application blocks from Enterprise Library



Code: There are appropriate comments give to explain its operation

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Web;

using System.Data;

using System.Data.Sql;

using System.Data.SqlClient;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using Microsoft.ApplicationBlocks.Data;

namespace Newwebpart1


public class Newwebpart1 : WebPart


protected override void CreateChildControls()



//Control can be created here...


protected override void Render(System.Web.UI.HtmlTextWriter writer)


//We Create a SQL connection

SqlConnection objSqlConnection = new SqlConnection("Data Source=;Initial Catalog=<YOUDB>;Persist Security Info=True;User ID=<USERNAME>;Password=<PASSWORD>");

//We execute a SQL Query & get a Dataset in return

DataSet objDataSet = SqlHelper.ExecuteDataset(objSqlConnection, System.Data.CommandType.Text, "SELECT [COL1],[COL2] FROM [DB].[dbo].[TABLENAME]");

//We are creating a Table in runtime

Table objTable = new Table();

objTable.BorderStyle = BorderStyle.Solid;

objTable.BorderWidth = 1;

objTable.GridLines = GridLines.Both;

objTable.CellPadding = 1;

objTable.CellSpacing = 1;

objTable.BorderColor = System.Drawing.Color.Blue;

//Creating Header here:

TableRow objTableRow_Header = new TableRow();

TableCell objTableCell_Title1 = new TableCell();

objTableCell_Title1.Text = objDataSet.Tables[0].Columns[0].Caption;

TableCell objTableCell_Title2 = new TableCell();

objTableCell_Title2.Text = objDataSet.Tables[0].Columns[1].Caption;




//Rows are added based on the number of records

for (int i = 0; i < objDataSet.Tables[0].Rows.Count; i++)


TableRow objTableRow_Content = new TableRow();

TableCell objTableCell_Column1 = new TableCell();

objTableCell_Column1.Text = objDataSet.Tables[0].Rows[i][0].ToString();

TableCell objTableCell_Column2 = new TableCell();

objTableCell_Column2.Text = objDataSet.Tables[0].Rows[i][1].ToString();





//Writing content inside webpart with the help of object created for


writer.Write("<div style='overflow:auto'>");

//Add the table which was created in runtime from the above code.







Download Project:

Steps to deploy a webpart:

1. Right click on project file and select properties and strong name key for the Project.

2. Build the solution (Ctrl+ Shit +B)

3. The Assembly (dll) will be created in the bin folder.

4. Move the assembly to the GAC ( just drag & drop in C:\WINDOWS\assembly)

5. In the web.config of the Web application (Sharepoint Website) place the code in SafeControls tag with the PublicKeyToken found in the Assembly.

SafeControl Assembly=", Version=, Culture=neutral, PublicKeyToken=ASDFASDRTERFSDF" Namespace="" TypeName="*" Safe="True"

6. Reset IIS

7. Go to Site Action -> Settings -> Webparts -> New

8. You will find your webpart in the URL: http://YOURMOSSSERVER/_layouts/NewDwp.aspx .Select the checkbox for the respective webpart & click Populate Gallery Button.

9. Now go to any page in the site and in Edit mode you will be able to find the webpart to add it in your page.... Thats it...

Note: With the help of Web Part templates in visual studio the above steps are made much more easier! you can just click on RUN button. The studio it-self will deploy & reset the IIS, you can directly go to the page and add the Web part! Love you Templates :)

Hope it helps... try and have fun :)

Fauzi ~4Z