A Practical Guide to SharePoint 2013

A Practical Guide to SharePoint 2013
A Practical Guide to SharePoint 2013 - Book by Saifullah Shafiq

Thursday, February 22, 2007

TechnoPart Source Code


Click here to download complete application (source code).
TechnoPart is a web part that displays your blog or site information, pulled from Technorati.com, in SharePoint sites. Click here to read more about TechnoPart.
Development Environment: MOSS 2007, .NET Framework 2.0, VS 2005
Programming Language:
C#

Download and unzip TechnoPart.zip file on your hard disk. It will create a folder TechnoPart. There will be two folders (projects) inside this TechnoPart folder:
1. Technocab -> This is the setup project.
2. WS-DLWP -> This is the web part project.

And there is a WS-DLWP.sln solution file along with these two folders. Double click this solution file to open the project in Visual Studio 2005.
GetSiteData() is the function that connects with Technorati through the API.
public void GetSiteData ()
{

BuildUrl();

string strURL = apiUrl + "bloginfo?" + queryString;

try
{

XmlTextReader _reader = new XmlTextReader(strURL.ToString());

//Read elements

while (_reader.Read())
{
if (_reader.NodeType == XmlNodeType.Element && _reader.Name == "rank")
{
_lblRank.Text =_reader.ReadElementString("rank");
}
else if (_reader.NodeType == XmlNodeType.Element && _reader.Name == "inboundblogs")
{
_lblBlogs.Text = _reader.ReadElementString("inboundblogs");
}
else if (_reader.NodeType == XmlNodeType.Element && _reader.Name == "inboundlinks")
{
_lblLinks.Text = _reader.ReadElementString("inboundlinks");
}
else if (_reader.NodeType == XmlNodeType.Element && _reader.Name == "name")
{
_lblName.Text = _reader.ReadElementString("name");
}
else if (_reader.NodeType == XmlNodeType.Element && _reader.Name == "firstname")
{
_lblAuthor.Text = _reader.ReadElementString("firstname");
}
else if (_reader.NodeType == XmlNodeType.Element && _reader.Name == "lastname")
{
_lblAuthor.Text = _lblAuthor.Text + " " + _reader.ReadElementString("lastname");
}
}

//Close the XML reader
_reader.Close();

}

catch (WebException ex)
{
_lblError.Text = ex.Message;
_lblError.CssClass = "error";
}
Add a style to the web part:
//Create a stylesheet
HtmlGenericControl stylesheet = new HtmlGenericControl("style");
stylesheet.InnerHtml = ReplaceTokens(Constants.Styles);
this.Controls.Add(stylesheet);
Build the interface:
 // Build up the table that is our user interface.
Table t = new Table();
TableRow trRank = BuildTableRow();
TableRow trBlogs = BuildTableRow();
TableRow trLinks = BuildTableRow();
TableRow trError = BuildTableRow();
TableRow trName = BuildTableRow();
TableRow trAuthor = BuildTableRow();

trName.Cells[0].Text = "Name: ";
trName.Cells[1].ForeColor = System.Drawing.Color.Green;
trName.Cells[1].Font.Bold = true;
trName.Cells[1].Font.Size = FontUnit.Medium;
trName.Cells[1].Controls.Add(_lblName);

trAuthor.Cells[0].Text = "Author: ";
trAuthor.Cells[1].ForeColor = System.Drawing.Color.Green;
trAuthor.Cells[1].Font.Bold = true;
trAuthor.Cells[1].Font.Size = FontUnit.Medium;
trAuthor.Cells[1].Controls.Add(_lblAuthor);

trRank.Cells[0].Text = "Rank: ";
trRank.Cells[1].ForeColor = System.Drawing.Color.Green;
trRank.Cells[1].Font.Bold = true;
trRank.Cells[1].Font.Size = FontUnit.Medium;
trRank.Cells[1].Controls.Add(_lblRank);

trBlogs.Cells[0].Text = "Inbound Blogs: ";
trBlogs.Cells[1].ForeColor = System.Drawing.Color.Green;
trBlogs.Cells[1].Font.Bold = true;
trBlogs.Cells[1].Font.Size = FontUnit.Medium;
trBlogs.Cells[1].Controls.Add(_lblBlogs);

trLinks.Cells[0].Text = "Inbound Links: ";
trLinks.Cells[1].ForeColor = System.Drawing.Color.Green;
trLinks.Cells[1].Font.Bold = true;
trLinks.Cells[1].Font.Size = FontUnit.Medium;
trLinks.Cells[1].Controls.Add(_lblLinks);

trError.Cells[0].Text = "";
trError.Cells[1].Controls.Add(_lblError);

t.Rows.AddRange(new TableRow[]{
trName,
trAuthor,
trRank,
trBlogs,
trLinks,
trError
});

this.Controls.Add(t);
Click here to download complete application (source code).
-------------
Update:
Originally posted: Fri, Feb 23, 2007
Reposted: Aug 26, 2007
Some of the links might not work as this version was retrieved from a web archive. If you find any dead links, kindly send an email to share.point@yahoo.com with the URL of this page. Thank you!
-------------------------