<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Gitolekha's Tech Weblog</title>
	<atom:link href="http://techolyvia.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://techolyvia.wordpress.com</link>
	<description>Just another WordPress.com weblog</description>
	<lastBuildDate>Wed, 23 Sep 2009 14:58:48 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='techolyvia.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/09f80cb823106f5c73a4e631e7d03dd0?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Gitolekha's Tech Weblog</title>
		<link>http://techolyvia.wordpress.com</link>
	</image>
			<item>
		<title>How to check MS Office version of client machine and edit documents on the fly.</title>
		<link>http://techolyvia.wordpress.com/2009/09/23/how-to-check-ms-office-version-of-client-machine-and-edit-documents-on-the-fly/</link>
		<comments>http://techolyvia.wordpress.com/2009/09/23/how-to-check-ms-office-version-of-client-machine-and-edit-documents-on-the-fly/#comments</comments>
		<pubDate>Wed, 23 Sep 2009 14:58:48 +0000</pubDate>
		<dc:creator>techolyvia</dc:creator>
				<category><![CDATA[Sharepoint]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[ActiveXObject]]></category>
		<category><![CDATA[edit in Microsoft Word]]></category>
		<category><![CDATA[SharePoint OpenDocuments]]></category>
		<category><![CDATA[STSUpld UploadCtl]]></category>
		<category><![CDATA[Upload multiple files]]></category>

		<guid isPermaLink="false">http://techolyvia.wordpress.com/?p=126</guid>
		<description><![CDATA[My friend asked me that he has a document repository site in sharepoint and wants to edit the documents online.
 Much like the “edit in Microsoft Word” option of sharepoint, but he needed to do that programmatically.
Such features are available in MS Office 2007 version.So, my friend first needed to check the MS Office version of [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techolyvia.wordpress.com&blog=2264071&post=126&subd=techolyvia&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>My friend asked me that he has a document repository site in sharepoint and wants to edit the documents online.</p>
<p> Much like the “edit in Microsoft Word” option of sharepoint, but he needed to do that programmatically.</p>
<p>Such features are available in MS Office 2007 version.So, my friend first needed to check the MS Office version of the client machine. As you know, it is very difficult to get software information of the client machine through web applications.</p>
<p>My friend tried various options,he checked the registry but it only returned the servers information not the clients.</p>
<p>After searching the net for long, the sharepoint upload page gave him a good idea.</p>
<p>He noticed that the “Upload multiple files” is shown in some versions and not in others. Digging deep he found the “Upload Multiple Documents” feature is an ActiveX control that installs with Office 2003/2007 so if you aren’t running either Office versions then the option won’t show up in SharePoint. This ActiveX control is called STSUpld.UploadCtl.</p>
<p>Now that we know which activeX control to call to check the version of office, now we need to edit the document online as it can be done through “Edit in Microsoft office word”.</p>
<p>After seraching the net, I found an ActiveX control that allows users to edit documents with their associated applications in the context of Microsoft Windows SharePoint Services called OpenDocuments Control.</p>
<p>So, in the final code, first we check whether STSUpld.UploadCtl exists or not and then we call OpenDocuments axtiveX to edit the document on the fly.</p>
<p>The javascript for this is shown below:</p>
<p>function EditDoconFly(strDocument){var objEditor;var objactivex; try{if(objactivex = new ActiveXObject(&#8216;STSUpld.UploadCtl&#8217;)){objEditor = new ActiveXObject(&#8216;SharePoint.OpenDocuments.1&#8242;);if(objEditor){ objEditor.EditDocument(strDocument, &#8221;); }else{ alert(&#8216;Cannot edit documents on fly below Microsoft Office 2007&#8242;);  }objactivex = &#8221;;objEditor=&#8221;;}else{alert(&#8216;Cannot edit documents on fly below Microsoft Office 2007&#8242;);}}catch(e){alert(&#8216;Cannot edit documents on fly below Microsoft Office 2007&#8242;);} return false;}<strong> </strong></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/techolyvia.wordpress.com/126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/techolyvia.wordpress.com/126/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/techolyvia.wordpress.com/126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/techolyvia.wordpress.com/126/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/techolyvia.wordpress.com/126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/techolyvia.wordpress.com/126/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/techolyvia.wordpress.com/126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/techolyvia.wordpress.com/126/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/techolyvia.wordpress.com/126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/techolyvia.wordpress.com/126/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techolyvia.wordpress.com&blog=2264071&post=126&subd=techolyvia&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://techolyvia.wordpress.com/2009/09/23/how-to-check-ms-office-version-of-client-machine-and-edit-documents-on-the-fly/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1ac0ccfaf4d6cbf2dcb01b07cbd4f3fb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">techolyvia</media:title>
		</media:content>
	</item>
		<item>
		<title>Playing with datatables&#8230;</title>
		<link>http://techolyvia.wordpress.com/2009/07/13/playing-with-datatables/</link>
		<comments>http://techolyvia.wordpress.com/2009/07/13/playing-with-datatables/#comments</comments>
		<pubDate>Mon, 13 Jul 2009 12:18:36 +0000</pubDate>
		<dc:creator>techolyvia</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Adding a datatacolumn to datatable and populating it with default values]]></category>
		<category><![CDATA[adding row in datatable]]></category>
		<category><![CDATA[edit a row in datatable]]></category>
		<category><![CDATA[how to remove duplicate rows from datatable]]></category>
		<category><![CDATA[select method of datatable]]></category>

		<guid isPermaLink="false">http://techolyvia.wordpress.com/?p=117</guid>
		<description><![CDATA[Well, everyone has worked with datatables sometime or the other. In this article, I just wanted to illustrate the various usage and implementation of datatables.
The DataTable object represents tabular data as rows, columns, and constraints.Use the DataTable object to hold data in memory while performing disconnected data operations.Datatable consists of DataColumn and DataRow.
The DataTable object [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techolyvia.wordpress.com&blog=2264071&post=117&subd=techolyvia&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Well, everyone has worked with datatables sometime or the other. In this article, I just wanted to illustrate the various usage and implementation of datatables.</p>
<p>The DataTable object represents tabular data as rows, columns, and constraints.Use the DataTable object to hold data in memory while performing disconnected data operations.Datatable consists of DataColumn and DataRow.<br />
The DataTable object must contain DataColumn objects before any data can be added to the DataTable object.</p>
<p><strong> In this example, we have a datatable with three columns, Name, Adress and Date of Joining(DOJ) which is a datetime column.</strong></p>
<p>dtResults = new DataTable();<br />
dtResults.Columns.Add(&#8220;Name&#8221;, Type.GetType(&#8220;System.String&#8221;));<br />
dtResults.Columns.Add(&#8220;Department&#8221;, Type.GetType(&#8220;System.String&#8221;));<br />
dtResults.Columns.Add(&#8220;DOJ&#8221;, Type.GetType(&#8220;System.DateTime&#8221;));</p>
<p><strong>Adding row to datatable:</strong><br />
dtResults.Rows.Add(&#8220;Olyvia&#8221;, &#8220;Developer&#8221;, DateTime.Now);</p>
<p><strong>Adding a datatacolumn to dtresults and populating it with default values</strong></p>
<p>dcRec = new DataColumn(&#8220;Age&#8221;, typeof(int));<br />
dcRec.DefaultValue = 23;<br />
dtResults.Columns.Add(dcRec);</p>
<p><strong>datatable Select</strong><br />
The DataTable Select method accepts a filter and sort argument to return an arry of DataRow objects that conform to the criteria in a FilterExpression.<br />
        DataRow[] drResultSet= dtResults.Select(&#8220;Age  &#8216;21&#8242;&#8221;);</p>
<p>To get the column name dynamically, see the example below:</p>
<p>DataRow[] drResultSet;<br />
drResultSet = dtResults.Select(site.Fields["ID"].InternalName + &#8220;=&#8217;&#8221; + dtStore.Rows[i]["DocUniqueID"].ToString().Substring(0, dtStore.Rows[i]["DocUniqueID"].ToString().IndexOf(&#8220;.&#8221;)) + &#8220;&#8216; and &#8221; + site.Fields["Title"].InternalName + &#8220;=&#8217;&#8221; + dtStore.Rows[i]["Title"] + &#8220;&#8216;&#8221;);</p>
<p><strong>How to remove duplicate rows from a datatable</strong><br />
If some rows of a some columns in the datatable are repititive and duplicate and you want to remove them, then see the example below:</p>
<p>DataColumn[] keyColumns = new DataColumn[] { dtStore.Columns["DocUniqueID"], dtStore.Columns["DocType"] };<br />
//remove the duplicates<br />
RemoveDuplicates(dtStore, keyColumns);</p>
<p>private static void RemoveDuplicates(DataTable tbl,DataColumn[] keyColumns)<br />
{<br />
  int rowNdx = 0;<br />
  while (rowNdx  0)<br />
     {<br />
         foreach (DataRow dup in dups)<br />
         {<br />
             tbl.Rows.Remove(dup);<br />
         }<br />
     }<br />
     else<br />
     {<br />
         rowNdx++;<br />
     }<br />
 }<br />
}</p>
<p>private static DataRow[] FindDups(DataTable tbl,int sourceNdx,DataColumn[] keyColumns)<br />
{<br />
 ArrayList retVal = new ArrayList();<br />
 DataRow sourceRow = tbl.Rows[sourceNdx];<br />
 for (int i = sourceNdx + 1; i &lt; tbl.Rows.Count; i++)<br />
 {<br />
     DataRow targetRow = tbl.Rows[i];<br />
     if (IsDup(sourceRow, targetRow, keyColumns))<br />
     {<br />
         retVal.Add(targetRow);<br />
     }<br />
 }<br />
 return (DataRow[])retVal.ToArray(typeof(DataRow));<br />
}</p>
<p>private static bool IsDup(DataRow sourceRow,DataRow targetRow,DataColumn[] keyColumns)<br />
{<br />
 bool retVal = true;<br />
 foreach (DataColumn column in keyColumns)<br />
 {<br />
     retVal = retVal &amp;&amp; sourceRow[column].Equals(targetRow[column]);<br />
     if (!retVal) break;<br />
 }<br />
 return retVal;<br />
}</p>
<p><strong>How to edit a row in datatable</strong></p>
<p>strName = &#8220;Gitolekha&#8221;;<br />
drResultSet[0]["Name"] = strName.ToString();<br />
dtResults.AcceptChanges();</p>
<p>Datatables have lots of features and functionality, I have just covered some of them, more will be covered next time.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/techolyvia.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/techolyvia.wordpress.com/117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/techolyvia.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/techolyvia.wordpress.com/117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/techolyvia.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/techolyvia.wordpress.com/117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/techolyvia.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/techolyvia.wordpress.com/117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/techolyvia.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/techolyvia.wordpress.com/117/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techolyvia.wordpress.com&blog=2264071&post=117&subd=techolyvia&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://techolyvia.wordpress.com/2009/07/13/playing-with-datatables/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1ac0ccfaf4d6cbf2dcb01b07cbd4f3fb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">techolyvia</media:title>
		</media:content>
	</item>
		<item>
		<title>Adding hyperlink in tablecell and open it in a new window.</title>
		<link>http://techolyvia.wordpress.com/2009/06/02/adding-hyperlink-in-tablecell-and-open-it-in-a-new-window/</link>
		<comments>http://techolyvia.wordpress.com/2009/06/02/adding-hyperlink-in-tablecell-and-open-it-in-a-new-window/#comments</comments>
		<pubDate>Tue, 02 Jun 2009 13:08:10 +0000</pubDate>
		<dc:creator>techolyvia</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Add hyperlink in tablecell using C#]]></category>
		<category><![CDATA[add styles in hyperlink in tablecell through C#]]></category>
		<category><![CDATA[navigateurl in new window]]></category>

		<guid isPermaLink="false">http://techolyvia.wordpress.com/?p=114</guid>
		<description><![CDATA[I was trying to create a table and add rows and cells in it using c#.
And tried to hyperlink in a tablecell, tried to add styles in the hyperlink without touching the css class and open the hyperlink popup via navigateurl in a new window.
putting hyperlink on tablecell:
TableRow tr = new TableRow();
TableCell td = new [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techolyvia.wordpress.com&blog=2264071&post=114&subd=techolyvia&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I was trying to create a table and add rows and cells in it using c#.</p>
<p>And tried to hyperlink in a tablecell, tried to add styles in the hyperlink without touching the css class and open the hyperlink popup via navigateurl in a new window.</p>
<p><strong>putting hyperlink on tablecell:</strong></p>
<p>TableRow tr = new TableRow();<br />
TableCell td = new TableCell();<br />
HyperLink hyper1 = new HyperLink();<br />
hyper1.NavigateUrl = &#8220;http://techolyvia.wordpress.com/category/technical/sharepoint/spgroup/&#8221;;<br />
hyper1.Text = &#8220;SPGroup&#8221;;<br />
td.Controls.Add(hyper1);<br />
tr.Cells.Add(td);<br />
tableOuterCtrl.Rows.Add(tr);</p>
<p><strong>Using navigateurl to open in a new window:</strong></p>
<p>hyper1.Target = &#8220;_blank&#8221;;</p>
<p><strong>Add styles in hyperlink without modifying css classes.</strong></p>
<p>hyper1.Style.Add(&#8220;font&#8221;, &#8220;normal 8pt Verdana;&#8221;);<br />
hyper1.Style.Add(&#8220;color&#8221;, &#8220;black&#8221;);</p>
<p><strong>full code goes like this:</strong><br />
 tableOuterCtrl = new Table();<br />
 tableOuterCtrl.CellPadding = 0;<br />
 tableOuterCtrl.CellSpacing = 0;<br />
 Controls.Add(tableOuterCtrl);<br />
TableRow tr;<br />
 TableCell td;<br />
 tr = new TableRow();<br />
 tr.Width = Unit.Percentage(100);<br />
 tableOuterCtrl.Rows.Add(tr);<br />
 td = new TableCell();<br />
 HyperLink hyper1 = new HyperLink();<br />
 td.Wrap = false;<br />
 td.Width = Unit.Percentage(100);<br />
 hyper1.Style.Add(&#8220;font&#8221;, &#8220;normal 8pt Verdana;&#8221;);<br />
 hyper1.Style.Add(&#8220;color&#8221;, &#8220;black&#8221;);<br />
 hyper1.NavigateUrl = &#8220;http://techolyvia.wordpress.com/2009/03/31/report-to-show-all-users-and-user-groups-in-sharepoint-site/&#8221;;<br />
 hyper1.Target = &#8220;_blank&#8221;;<br />
 hyper1.Text = &#8220;Displaying all users and groups through coding&#8221;;<br />
 td.Controls.Add(hyper1);<br />
 tr.Cells.Add(td);<br />
tableOuterCtrl.Rows.Add(tr);<br />
this.Controls.Add(tableOuterCtrl);</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/techolyvia.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/techolyvia.wordpress.com/114/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/techolyvia.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/techolyvia.wordpress.com/114/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/techolyvia.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/techolyvia.wordpress.com/114/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/techolyvia.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/techolyvia.wordpress.com/114/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/techolyvia.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/techolyvia.wordpress.com/114/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techolyvia.wordpress.com&blog=2264071&post=114&subd=techolyvia&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://techolyvia.wordpress.com/2009/06/02/adding-hyperlink-in-tablecell-and-open-it-in-a-new-window/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1ac0ccfaf4d6cbf2dcb01b07cbd4f3fb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">techolyvia</media:title>
		</media:content>
	</item>
		<item>
		<title>url encoding through javascript and custom http module to handle encoded url</title>
		<link>http://techolyvia.wordpress.com/2009/05/28/url-encoding-through-javascript-and-custom-http-module-to-handle-encoded-url/</link>
		<comments>http://techolyvia.wordpress.com/2009/05/28/url-encoding-through-javascript-and-custom-http-module-to-handle-encoded-url/#comments</comments>
		<pubDate>Thu, 28 May 2009 10:29:04 +0000</pubDate>
		<dc:creator>techolyvia</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[custom HTTPModule]]></category>
		<category><![CDATA[javascript encoding]]></category>
		<category><![CDATA[javascript remove blank spaces from string]]></category>
		<category><![CDATA[replace all occurences in a string using javascript]]></category>

		<guid isPermaLink="false">http://techolyvia.wordpress.com/?p=109</guid>
		<description><![CDATA[An user might want to email an url like the one given below:
http://gitolekha:82/default.aspx?ConnectSearch=good sharepoint blog
We need to do url encoding to send such links because often url&#8217;s contain characters outside the ASCII set, so URL encoding converts the url to valid ASCII sets.URL encoding replaces unsafe ASCII characters with &#8220;%&#8221; followed by two hexadecimal digits [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techolyvia.wordpress.com&blog=2264071&post=109&subd=techolyvia&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>An user might want to email an url like the one given below:<br />
http://gitolekha:82/default.aspx?ConnectSearch=good sharepoint blog</p>
<p>We need to do url encoding to send such links because often url&#8217;s contain characters outside the ASCII set, so URL encoding converts the url to valid ASCII sets.URL encoding replaces unsafe ASCII characters with &#8220;%&#8221; followed by two hexadecimal digits corresponding to the character values in the ISO-8859-1 character-set.</p>
<p>URLs cannot contain spaces. URL encoding normally replaces a space with a + sign or as %20.</p>
<p>To do url encoding with .NET,one usually uses System.WebHttpUtility.UrlEncode to encode the querystring.</p>
<p>I had to do this through javascript.There are methods like<br />
escape(string) to do encoding, but it did not work for me.<br />
So, what I chose is the replace mothod to replace all unsafe characters.<br />
what I used is regular expression to <strong>replace all occurences</strong> <strong>of space in  string </strong>&#8220;good sharepoint blog&#8221; as <strong>encodestring.replace(/\\s+/g ,&#8217;$-*&#8217;);</strong></p>
<p>A detailed explaination of the above is as follows,<br />
/ = start pattern<br />
, = pattern to look for in the string badtext<br />
/ = end pattern<br />
g = global (anywhere the pattern match occurs in the string)<br />
&#8220;$-*&#8221; = what to replace the pattern with if found</p>
<p>So, the full code to send the encoded url in email is given below.</p>
<p>parent.location = &#8216;mailto:?body=&#8221; + HttpUtility.UrlEncode(SPContext.Current.Web.Url + &#8220;/default.aspx?ConnectSearch=&#8221;) + &#8220;&#8216;+txtSearch.value.replace(/\\s+/g ,&#8217;$-*&#8217;)+&#8217;~-~User=&#8217;+txtTopicsSearch.value.replace(/\\s+/g ,&#8217;$-*&#8217;)+&#8217;~-~Place=&#8217;+txtDocTypeSearch.value.replace(/\\s+/g ,&#8217;$-*&#8217;)+&#8217;~-~Country=&#8217;+txtCountrySearch.value.replace(/\\s+/g ,&#8217;$-*&#8217;)+&#8217;&amp;subject=site search link&#8217;</p>
<p>The mail has a subject line of &#8217;site search link&#8217; as seen above.</p>
<p>This emails the encoded url as,<br />
http://gitolekha:82/default.aspx?ConnectSearch=good$-*sharepoint$-*blog~-~User=gitolekha~-~Place=any$-*where/$-*in$-*India~-~Country=All$-*geographic$-*scopes</p>
<p>Now when the user types/paste the above url in the browser, we can use httphandler to make the application decode the above url in the desired format.<br />
Now, we know that an ASP.NET HTTP handler is the process that runs in response to a request that is made to an ASP.NET Web application. When users request an .aspx file, the request is processed by the page handler.An IHttpModule is registered in the Web.Config file and it is notified of every HTTP request.<br />
IHttpModule is an interface defined in System.Web.dll. The interface contains only two method signatures: Init and Dispose. On the Init method wire up, the behavior—for example application events—that you want the IHttpModule to support and perform any clean up in the Dispose method.</p>
<p>using System.Web;<br />
namespace Gitolekha.Sample.KnowledgeManagement<br />
{<br />
class CustomHandler : IHttpModule<br />
{<br />
public void Dispose()<br />
{<br />
//throw new Exception(&#8220;The method or operation is not implemented.&#8221;);<br />
}<br />
public void Init(HttpApplication context)<br />
{<br />
context.BeginRequest+=new EventHandler(context_BeginRequest);<br />
}<br />
public void context_BeginRequest(object sender, EventArgs e)<br />
{<br />
HttpApplication app = (HttpApplication)sender;<br />
string requestedPage = app.Request.RawUrl;<br />
if (requestedPage.Contains(&#8220;?ConnectSearch=&#8221;))<br />
{<br />
string strurl = app.Request.Url.AbsoluteUri;<br />
if (strurl .Contains(&#8220;$-*&#8221;))<br />
{<br />
strurl = strurl.<strong>Replace(&#8220;$-*&#8221;, &#8221; &#8220;);</strong><br />
}<br />
if (strurl.Contains(&#8220;~-~&#8221;))<br />
{<br />
strurl = strurl.<strong>Replace(&#8220;~-~&#8221;, &#8220;&amp;&#8221;);</strong><br />
}<br />
string strencode = HttpUtility.UrlEncode(strurl );<br />
HttpContext.Current.Response.Redirect(strurl, true);<br />
}}</p>
<p>This will do the required decoding for this url.<br />
Possible scenarios/reasons for users wanting to send url might be Sometimes it is easy for users to email interesting links of a site to another user.To elaborate, suppose you have a document management system where the users like to share interesting and important links of documents to other users through emails.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/techolyvia.wordpress.com/109/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/techolyvia.wordpress.com/109/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/techolyvia.wordpress.com/109/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/techolyvia.wordpress.com/109/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/techolyvia.wordpress.com/109/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/techolyvia.wordpress.com/109/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/techolyvia.wordpress.com/109/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/techolyvia.wordpress.com/109/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/techolyvia.wordpress.com/109/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/techolyvia.wordpress.com/109/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techolyvia.wordpress.com&blog=2264071&post=109&subd=techolyvia&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://techolyvia.wordpress.com/2009/05/28/url-encoding-through-javascript-and-custom-http-module-to-handle-encoded-url/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1ac0ccfaf4d6cbf2dcb01b07cbd4f3fb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">techolyvia</media:title>
		</media:content>
	</item>
		<item>
		<title>Report to show all users and user groups in sharepoint site</title>
		<link>http://techolyvia.wordpress.com/2009/03/31/report-to-show-all-users-and-user-groups-in-sharepoint-site/</link>
		<comments>http://techolyvia.wordpress.com/2009/03/31/report-to-show-all-users-and-user-groups-in-sharepoint-site/#comments</comments>
		<pubDate>Tue, 31 Mar 2009 13:46:30 +0000</pubDate>
		<dc:creator>techolyvia</dc:creator>
				<category><![CDATA[SPGroup]]></category>
		<category><![CDATA[show all users and their user groups]]></category>
		<category><![CDATA[SiteGroups]]></category>
		<category><![CDATA[SPGroupCollection]]></category>

		<guid isPermaLink="false">http://techolyvia.wordpress.com/?p=98</guid>
		<description><![CDATA[To view users in Sharepoint we have to ge to http://servername/_layouts/people.aspx. There we can see all user groups and users added to each group. Remembering this path might be easy for sharepoint developers but what about common users who want to view a report displaying all users, their email id and usergroups?
To do this, we [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techolyvia.wordpress.com&blog=2264071&post=98&subd=techolyvia&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>To view users in Sharepoint we have to ge to <a href="http://servername/_layouts/people.aspx">http://servername/_layouts/people.aspx</a>. There we can see all user groups and users added to each group. Remembering this path might be easy for sharepoint developers but what about common users who want to view a report displaying all users, their email id and usergroups?</p>
<p>To do this, we need to do some amount of custom coding&#8230;. which is shown below.</p>
<p><em><span style="color:#993300;">protected void Page_Load(object sender, EventArgs e)<br />
{<br />
string siteUrl = SPControl.GetContextSite(Context).Url;<br />
SPSecurity.RunWithElevatedPrivileges(delegate()<br />
{<br />
string Globaltbl = string.Empty;<br />
using (SPSite ospSite = new SPSite(siteUrl))<br />
{<br />
using (SPWeb site = ospSite.OpenWeb())<br />
{<br />
try<br />
{<br />
SPGroupCollection groups = site.SiteGroups;<br />
dtUserTable.Columns.Add(new DataColumn(&#8220;Name&#8221;, typeof(string)));<br />
dtUserTable.Columns.Add(new DataColumn(&#8220;Email&#8221;, typeof(string)));<br />
dtUserTable.Columns.Add(new DataColumn(&#8220;Group&#8221;, typeof(string)));<br />
Globaltbl += &#8220;&lt;table width=&#8217;100%&#8217; border=&#8217;0&#8242; cellpadding=&#8217;6&#8242; cellspacing=&#8217;4&#8242; &gt;&#8221;;<br />
Globaltbl += &#8220;&lt;tr&gt;&lt;th align=&#8217;left&#8217; style=&#8217;width:33%; font-family:verdana, Arial ;font-size:11px; color:#000000;&#8217;&gt;Name&lt;/th&gt;&lt;th align=&#8217;left&#8217; style=&#8217;width:34%; font-family:verdana, Arial ;font-size:11px; color:#000000;&#8217;&gt;Email&lt;/th&gt;&lt;th align=&#8217;left&#8217; style=&#8217;width:33%; font-family:verdana, Arial ;font-size:11px; color:#000000;&#8217;&gt;Group Name&lt;/th&gt;&lt;/tr&gt;&#8221;;<br />
foreach (SPGroup grp in groups)<br />
{</span></em></p>
<p><em><span style="color:#993300;">if (grp != null)<br />
{<br />
SPUserCollection users = grp.Users;<br />
if (users != null)<br />
{<br />
if (users.Count &gt; 0)<br />
{<br />
foreach (SPUser user in users)<br />
{<br />
Globaltbl += &#8220;&lt;tr width=&#8217;100%&#8217;&gt;&lt;td style=&#8217;width:33%; font-family:verdana, Arial ;font-size:11px; color:#000000;&#8217;&gt;&#8221; + user.Name.ToString() + &#8220;&lt;/td&gt;&lt;td style=&#8217;width:34%; font-family:verdana, Arial ;font-size:11px; color:#000000;&#8217;&gt;&#8221; + user.Email.ToString() + &#8220;&lt;/td&gt;&lt;td style=&#8217;width:33%; font-family:verdana, Arial ;font-size:11px; color:#000000;&#8217;&gt;&#8221; + grp.Name.ToString() + &#8220;&lt;/td&gt;&lt;/tr&gt;&#8221;;<br />
DataRow temprow = dtUserTable.NewRow();<br />
temprow["Name"] = user.Name.ToString();<br />
temprow["Email"] = user.Email.ToString();<br />
temprow["Group"] = grp.Name.ToString();<br />
dtUserTable.Rows.Add(temprow);<br />
temprow = null;<br />
}<br />
}<br />
}<br />
}<br />
}<br />
Globaltbl += &#8220;&lt;/table&gt;&#8221;;<br />
Page.Controls.Add(new LiteralControl(Globaltbl.Trim()));<br />
}<br />
catch (Exception ex)<br />
{<br />
SPUtility.HandleAccessDenied(ex);<br />
}<br />
finally<br />
{<br />
site.Dispose();<br />
ospSite.Dispose();<br />
}<br />
}<br />
}<br />
});<br />
}</span></em></p>
<p><span style="color:#000000;">This will display the user records on the web page as:</span></p>
<p> </p>
<p> </p>
<table border="0" cellspacing="4" cellpadding="6" width="100%">
<tbody>
<tr>
<th align="left">Name</th>
<th align="left">Email</th>
<th align="left">Group Name</th>
</tr>
<tr>
<td style="font-size:11px;width:33%;color:#000000;font-family:verdana, Arial;">Gitolekha Ray</td>
<td style="font-size:11px;width:34%;color:#000000;font-family:verdana, Arial;"><a href="mailto:gitolekha.ray@someplace.com">gitolekha.ray@someplace.com</a></td>
<td style="font-size:11px;width:33%;color:#000000;font-family:verdana, Arial;">Admin</td>
</tr>
<tr>
<td style="font-size:11px;width:33%;color:#000000;font-family:verdana, Arial;">Charles Dickens</td>
<td style="font-size:11px;width:34%;color:#000000;font-family:verdana, Arial;"><a href="mailto:charles.dickens@someplace.com">charles.dickens@someplace.com</a></td>
<td style="font-size:11px;width:33%;color:#000000;font-family:verdana, Arial;">Visitor</td>
</tr>
</tbody>
</table>
<p> </p>
<p><span style="color:#993300;">  </span>This will open a web page displaying all users in the system, their name, email address and user group. In case the user profile only contains the user id and not the name, you can write code to fetch it from the LDAP. You can also export the data to excel so that the user finds it easy to view the records.</p>
<p>The below code is only to show, how to export this data to excel, so that the user can view the user details exactly as shown above in excel, so the code to export to excel is shown below:</p>
<p>This will export the user details to excel in exactly the same format as shown above, so that the user finds it easy to search for a user and see which group he belongs to rather than remembering the complicated sharepoint url.</p>
<p> <br />
 <em><span style="color:#0000ff;">protected void btnExport_Click(object sender, EventArgse)<br />
{</span></em></p>
<p><em><span style="color:#0000ff;"> string defaultFileName = “UsersReport.xls”;<br />
 Response.ClearContent();<br />
 Response.AddHeader(“content-disposition”, “attachment;filename=”+ defaultFileName);<br />
 Response.ContentType = “application/excel”;<br />
 this.EnableViewState = false;<br />
 Response.Charset = “”;<br />
 StringWriter sw = new StringWriter();<br />
 HtmlTextWriter hw = new HtmlTextWriter(sw);<br />
}</span></em></p>
<p><em><span style="color:#0000ff;"> <br />
public string CreateExcelFile(DataTable dt)<br />
{<br />
 SPSite site = SPContext.Current.Site;<br />
 SPWeb web = site.OpenWeb();<br />
 string sTableStart = “&lt;HTML&gt;&lt;BODY&gt;&lt;TABLE Border=1&gt;”;<br />
 string sTableEnd = “&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;”;<br />
 string sTHead = “&lt;TR&gt;”;<br />
 StringBuilder sTableData = new StringBuilder();<br />
  try<br />
  {</span></em></p>
<p><em><span style="color:#0000ff;">  sTHead += “&lt;th scope=’col’&gt;Name&lt;/th&gt;&lt;th scope=’col’&gt;Email&lt;/th&gt;&lt;th scope=’col’&gt;Group   Name&lt;/th&gt;&lt;/tr&gt;”;<br />
    foreach (DataRow row in dt.Rows)<br />
    {<br />
 sTableData.Append(“&lt;TR&gt;”);<br />
 sTableData.Append(“&lt;TD&gt;” + row["Name"] + “&lt;/TD&gt;”);<br />
 sTableData.Append(“&lt;TD&gt;” + row["Email"] + “&lt;/TD&gt;”);<br />
 sTableData.Append(“&lt;TD&gt;” + row["Group"] + “&lt;/TD&gt;”);<br />
  sTableData.Append(“&lt;/TR&gt;”);<br />
    }<br />
  }<br />
  catch (Exception ex)<br />
  {<br />
 throw ex;<br />
  }<br />
  finally<br />
  {<br />
 site.Close();<br />
 site.Dispose();<br />
 web.Close();<br />
 web.Dispose();<br />
  }<br />
  string sTable = sTableStart + sTHead + sTableData.ToString() + sTableEnd;<br />
  return sTable;<br />
}</span></em></p>
<p><span style="color:#000000;">This will open the excel file in exactly the same format as the web page appears.</span></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/techolyvia.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/techolyvia.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/techolyvia.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/techolyvia.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/techolyvia.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/techolyvia.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/techolyvia.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/techolyvia.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/techolyvia.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/techolyvia.wordpress.com/98/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techolyvia.wordpress.com&blog=2264071&post=98&subd=techolyvia&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://techolyvia.wordpress.com/2009/03/31/report-to-show-all-users-and-user-groups-in-sharepoint-site/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1ac0ccfaf4d6cbf2dcb01b07cbd4f3fb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">techolyvia</media:title>
		</media:content>
	</item>
		<item>
		<title>Accessing User collection of SPGroup giving Access Denied error</title>
		<link>http://techolyvia.wordpress.com/2009/03/31/accessing-user-collection-of-spgroup-giving-access-denied-error/</link>
		<comments>http://techolyvia.wordpress.com/2009/03/31/accessing-user-collection-of-spgroup-giving-access-denied-error/#comments</comments>
		<pubDate>Tue, 31 Mar 2009 12:49:54 +0000</pubDate>
		<dc:creator>techolyvia</dc:creator>
				<category><![CDATA[SPGroup]]></category>
		<category><![CDATA[Access Denied]]></category>
		<category><![CDATA[RunWithElevatedPrivileges]]></category>
		<category><![CDATA[SPWeb SiteGroups]]></category>
		<category><![CDATA[User collection of SPGroup]]></category>

		<guid isPermaLink="false">http://techolyvia.wordpress.com/?p=96</guid>
		<description><![CDATA[I was getting the Access Denied page when I tried to access the UsersCollection of a SPGroup Instance or SiteGroups of SPWeb object.
I used RunWithElevatedPrivileges to be able to access the users collection but all in vein.
After searching through the net, I found that all code should be inside elevated priviledge, because if we access [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techolyvia.wordpress.com&blog=2264071&post=96&subd=techolyvia&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><span style="color:darkblue;">I was getting the Access Denied page when I tried to access the UsersCollection of a SPGroup Instance or SiteGroups of SPWeb object.<br />
I used RunWithElevatedPrivileges to be able to access the users collection but all in vein.<br />
After searching through the net, I found that all code should be inside elevated priviledge, because if we access SiteGroups from a SPWeb object that was created prior to using elevated priviledge, the problem would still sustain.</p>
<p>So, I changed my code to define the objects inside elevated priviledges like:</span></p>
<p><span style="color:darkblue;"><em>SPSecurity.SPWeb (delegate()<br />
{       SPSite ospSite = SPContext.Current.Site;<br />
        SPWeb site = ospSite.OpenWeb();<br />
……code to access users<br />
}</em> </span></p>
<p><span style="color:darkblue;">The code was still giving errors because Context, SPContext or SPControl.GetWebContext, etc. cannot be used inside elevated privileges. The reason is that Context object is created before the code with elevated privileges is executed.</p>
<p>So, the change will be:</span></p>
<p><span style="color:darkblue;"> <em>string siteUrl = SPControl.GetContextSite(Context).Url;<br />
        SPSecurity.RunWithElevatedPrivileges(delegate()<br />
  {<br />
        string Globaltbl = string.Empty;<br />
        using (SPSite ospSite = new SPSite(siteUrl))<br />
        {<br />
            using (SPWeb oWeb = ospSite.OpenWeb())<br />
            {<br />
                    SPGroupCollection groups = oWeb.SiteGroups;  <br />
                    foreach (SPGroup grp in groups)<br />
                    {<br />
                        SPUserCollection users = grp.Users;<br />
                        if (users != null)<br />
                        {<br />
                            foreach (SPUser user in users)<br />
                            {<br />
                                //MyCode//<br />
                            }<br />
                        }<br />
                    }<br />
}<br />
}<br />
});</em></span></p>
<p><span style="color:darkblue;">And Voila! everything works just fine.<span style="color:#000000;"> </span></span></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/techolyvia.wordpress.com/96/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/techolyvia.wordpress.com/96/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/techolyvia.wordpress.com/96/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/techolyvia.wordpress.com/96/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/techolyvia.wordpress.com/96/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/techolyvia.wordpress.com/96/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/techolyvia.wordpress.com/96/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/techolyvia.wordpress.com/96/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/techolyvia.wordpress.com/96/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/techolyvia.wordpress.com/96/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techolyvia.wordpress.com&blog=2264071&post=96&subd=techolyvia&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://techolyvia.wordpress.com/2009/03/31/accessing-user-collection-of-spgroup-giving-access-denied-error/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1ac0ccfaf4d6cbf2dcb01b07cbd4f3fb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">techolyvia</media:title>
		</media:content>
	</item>
		<item>
		<title>Sort XML alphabetically using XSL</title>
		<link>http://techolyvia.wordpress.com/2009/02/10/sort-xml-alphabetically-using-xsl/</link>
		<comments>http://techolyvia.wordpress.com/2009/02/10/sort-xml-alphabetically-using-xsl/#comments</comments>
		<pubDate>Tue, 10 Feb 2009 12:49:24 +0000</pubDate>
		<dc:creator>techolyvia</dc:creator>
				<category><![CDATA[xml]]></category>
		<category><![CDATA[root element is missing]]></category>
		<category><![CDATA[sort XML alphabetically]]></category>
		<category><![CDATA[xsl]]></category>
		<category><![CDATA[xsltransform]]></category>

		<guid isPermaLink="false">http://techolyvia.wordpress.com/?p=94</guid>
		<description><![CDATA[One of my friends asked me how to sort a xml file which is deserialized and put into a treeview.
The xml lookes something like the one shown below:
  &#60;?xml version=&#8221;1.0&#8243; encoding=&#8221;us-ascii&#8221; ?&#62;
- &#60;TreeView&#62;
- &#60;node text=&#8221;Topics&#8221;&#62;
  &#60;node text=&#8221;Animal Health&#8221; /&#62; 
- &#60;node text=&#8221;Tools&#8221;&#62;
- &#60;node text=&#8221;Corporate&#8221;&#62;
   &#60;node text=&#8221;knowledge management&#8221; /&#62;
   &#60;node text=&#8221;Media relations&#8221; /&#62;
   &#60;node text=&#8221;Agency management&#8221; /&#62;
   &#60;node [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techolyvia.wordpress.com&blog=2264071&post=94&subd=techolyvia&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>One of my friends asked me how to sort a xml file which is deserialized and put into a treeview.<br />
The xml lookes something like the one shown below:</p>
<p><!--l version="1.0" encoding="us-ascii"-->  &lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;us-ascii&#8221; ?&gt;<br />
- &lt;TreeView&gt;<br />
- &lt;node text=&#8221;Topics&#8221;&gt;<br />
  &lt;node text=&#8221;Animal Health&#8221; /&gt; <br />
- &lt;node text=&#8221;Tools&#8221;&gt;<br />
- &lt;node text=&#8221;Corporate&#8221;&gt;<br />
   &lt;node text=&#8221;knowledge management&#8221; /&gt;<br />
   &lt;node text=&#8221;Media relations&#8221; /&gt;<br />
   &lt;node text=&#8221;Agency management&#8221; /&gt;<br />
   &lt;node text=&#8221;Messaging&#8221; /&gt;<br />
   &lt;node text=&#8221;Communications planning&#8221; /&gt;<br />
   &lt;node text=&#8221;Newsflow&#8221; /&gt;<br />
  &lt;/node&gt;<br />
  &lt;/node&gt;<br />
  &lt;/node&gt;<br />
  &lt;/node&gt;<br />
  &lt;/TreeView&gt;</p>
<p>As you can see the xml dosen&#8217;t look sorted, So in order to sort it alphabetically, xsl may be the<br />
easiest route. Here&#8217;s the transform to sort alphabetically:</p>
<p>&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;us-ascii&#8221; ?&gt;<br />
&lt;xsl:stylesheet version=&#8221;1.0&#8243; xmlns:xsl=&#8221;<a href="http://www.w3.org/1999/XSL/Transform">http://www.w3.org/1999/XSL/Transform</a>&#8221; xmlns:fo=&#8221;<a href="http://www.w3.org/1999/XSL/Format">http://www.w3.org/1999/XSL/Format</a>&#8220;&gt;<br />
&lt;xsl:template match=&#8221;node&#8221;&gt;<br />
            &lt;xsl:copy&gt;<br />
                  &lt;xsl:copy-of select=&#8221;@*&#8221;/&gt;<br />
&lt;xsl:apply-templates select=&#8221;node&#8221;&gt;<br />
      &lt;xsl:sort select=&#8221;@text&#8221;/&gt;<br />
&lt;/xsl:apply-templates&gt;<br />
 &lt;/xsl:copy&gt;<br />
      &lt;/xsl:template&gt;<br />
&lt;/xsl:stylesheet&gt;</p>
<p>Now, we can use XSL Transform to Transform the XML data using the loaded XSLT stylesheet. See the Code Below</p>
<p>string strSortFile = @&#8221;C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\sort.xsl&#8221;;<br />
string filename = @&#8221;C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\BizFocus.xml&#8221;;<br />
XmlDocument doc = new XmlDocument();<br />
doc.Load(fileName);<br />
MemoryStream sstream = new MemoryStream();<br />
// Modify the XML file.<br />
XmlElement root = doc.DocumentElement;<br />
// Create an XPathNavigator to use for the transform.<br />
XPathNavigator nav = root.CreateNavigator();<br />
// Transform the file.<br />
System.Xml.Xsl.XslTransform xtr = new System.Xml.Xsl.XslTransform();<br />
xtr.Load(strSortFile);<br />
//XmlTextWriter writer = new XmlTextWriter(fileName, null);<br />
XmlTextWriter writer1 = new XmlTextWriter(sstream, null);<br />
xtr.Transform(nav, null, writer1, null);<br />
XmlTextReader reader = null;<br />
<span style="color:#800000;">sstream.Position = 0;</span></p>
<p><span style="color:#008080;">/*Insert Logic to add node to treeview from XMLTextReader*/</span><br />
You might get the error &#8216;Root element is Missing&#8217;, but do not worry, it isn&#8217;t a problem with the input file or the transform script. The problem is that the XslTransform.Transform function leaves the stream position set to the end of the stream. There&#8217;s no root element because the XmlDocument.Load function thinks the stream has a 0 byte length. The fix is to simply set the <span style="color:#800000;">position to 0.</span></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/techolyvia.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/techolyvia.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/techolyvia.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/techolyvia.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/techolyvia.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/techolyvia.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/techolyvia.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/techolyvia.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/techolyvia.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/techolyvia.wordpress.com/94/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techolyvia.wordpress.com&blog=2264071&post=94&subd=techolyvia&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://techolyvia.wordpress.com/2009/02/10/sort-xml-alphabetically-using-xsl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1ac0ccfaf4d6cbf2dcb01b07cbd4f3fb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">techolyvia</media:title>
		</media:content>
	</item>
		<item>
		<title>read text file from document library and write content in textbox</title>
		<link>http://techolyvia.wordpress.com/2009/01/22/read-text-file-from-document-library-and-write-content-in-textbox/</link>
		<comments>http://techolyvia.wordpress.com/2009/01/22/read-text-file-from-document-library-and-write-content-in-textbox/#comments</comments>
		<pubDate>Thu, 22 Jan 2009 14:24:50 +0000</pubDate>
		<dc:creator>techolyvia</dc:creator>
				<category><![CDATA[Sharepoint]]></category>
		<category><![CDATA[read content of text file from sharepoint document library]]></category>
		<category><![CDATA[read from document library]]></category>

		<guid isPermaLink="false">http://techolyvia.wordpress.com/?p=92</guid>
		<description><![CDATA[Ever thought of creating files on the fly (say by typing contents  in a textbox) and saving them to the document library? refer to my previous post http://techolyvia.wordpress.com/2009/01/13/how-to-create-files-dynamically-and-save-that-in-document-library/ which talks about this.
Now, if we want to edit the uploaded data, we need to read the content from the document library and show the content in the textbox. So, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techolyvia.wordpress.com&blog=2264071&post=92&subd=techolyvia&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Ever thought of creating files on the fly (say by typing contents  in a textbox) and saving them to the document library? refer to my previous post <a href="http://techolyvia.wordpress.com/2009/01/13/how-to-create-files-dynamically-and-save-that-in-document-library/">http://techolyvia.wordpress.com/2009/01/13/how-to-create-files-dynamically-and-save-that-in-document-library/</a> which talks about this.</p>
<p>Now, if we want to edit the uploaded data, we need to read the content from the document library and show the content in the textbox. So, how do we do that? See the code below:</p>
<p>SPSite ospSite = SPContext.Current.Site;<br />
SPWeb ospWeb = ospSite.OpenWeb();<br />
<span style="color:#008000;">/*docPath returns the url of the file as <strong>sharepoint url/document library/filename</strong>*/<br />
</span>string docPath = Request.QueryString["Path"];<br />
SPFile tempFile = ospWeb.GetFile(docPath);<br />
<span style="color:#008000;">/*OpenBinaryStream() opens the file as a stream*/<br />
</span>StreamReader reader = new StreamReader(tempFile.OpenBinaryStream());<br />
<span style="color:#008000;">/*txtUpload is the textbox control where we insert the value of the text file*/<br />
</span>txtUploadText.Text = reader.ReadToEnd();<br />
reader.Close();</p>
<p><span style="color:#000000;">So, we use StreamReader to read the content of the text file in document library and display the content in a Multiline Textbox, so that the user can  edit the content of the textfile.</span></p>
<p><span style="color:#000000;">For details refer to <a href="http://www.dotnetspider.com/forum/189095-Read-file-content-from-document-library-write-textbox.aspx">http://www.dotnetspider.com/forum/189095-Read-file-content-from-document-library-write-textbox.aspx</a></span></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/techolyvia.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/techolyvia.wordpress.com/92/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/techolyvia.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/techolyvia.wordpress.com/92/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/techolyvia.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/techolyvia.wordpress.com/92/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/techolyvia.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/techolyvia.wordpress.com/92/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/techolyvia.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/techolyvia.wordpress.com/92/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techolyvia.wordpress.com&blog=2264071&post=92&subd=techolyvia&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://techolyvia.wordpress.com/2009/01/22/read-text-file-from-document-library-and-write-content-in-textbox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1ac0ccfaf4d6cbf2dcb01b07cbd4f3fb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">techolyvia</media:title>
		</media:content>
	</item>
		<item>
		<title>how to get value of selected node in a treeview</title>
		<link>http://techolyvia.wordpress.com/2009/01/13/how-to-get-value-of-selected-node-in-a-treeview/</link>
		<comments>http://techolyvia.wordpress.com/2009/01/13/how-to-get-value-of-selected-node-in-a-treeview/#comments</comments>
		<pubDate>Tue, 13 Jan 2009 14:48:44 +0000</pubDate>
		<dc:creator>techolyvia</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[selected node in treeview]]></category>
		<category><![CDATA[treeview checked node value]]></category>

		<guid isPermaLink="false">http://techolyvia.wordpress.com/?p=89</guid>
		<description><![CDATA[One of my colleague was using a treeview. He was not able to get the value of the node selected in a checkbox,the nodes were rendering in a td,say the name of the node is Apple and name of the treeview is tview :-
&#60;td&#62;&#60;div style=&#8221;width:20px;height:1px&#8221;&#62;&#60;/div&#62;&#60;/td&#62;&#60;td&#62;&#60;a id=&#8221;tviewn1&#8243; href=&#8221;javascript:TreeView_ToggleNode(tview_Data,1,tviewn1,&#8217; &#8216;,tviewn1Nodes)&#8221;&#62;&#60;img  alt=&#8221;Expand Apple&#8221; style=&#8221;border-width:0;&#8221; /&#62;&#60;/a&#62;&#60;/td&#62;&#60;td style=&#8221;white-space:nowrap;&#8221;&#62;&#60;input type=&#8221;checkbox&#8221; name=&#8221;tviewn1CheckBox&#8221; [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techolyvia.wordpress.com&blog=2264071&post=89&subd=techolyvia&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>One of my colleague was using a treeview. He was not able to get the value of the node selected in a checkbox,the nodes were rendering in a td,say the name of the node is Apple and name of the treeview is tview :-</p>
<p>&lt;td&gt;&lt;div style=&#8221;width:20px;height:1px&#8221;&gt;&lt;/div&gt;&lt;/td&gt;&lt;td&gt;&lt;a id=&#8221;tviewn1&#8243; href=&#8221;javascript:TreeView_ToggleNode(tview_Data,1,tviewn1,&#8217; &#8216;,tviewn1Nodes)&#8221;&gt;&lt;img  alt=&#8221;Expand Apple&#8221; style=&#8221;border-width:0;&#8221; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;td style=&#8221;white-space:nowrap;&#8221;&gt;&lt;input type=&#8221;checkbox&#8221; name=&#8221;tviewn1CheckBox&#8221; id=&#8221;tviewn1CheckBox&#8221; /&gt;&lt;span class=&#8221;tview_0&#8243; id=&#8221;tviewt1&#8243;&gt;Apple&lt;/span&gt;&lt;/td&gt;</p>
<p>The javascript to get the node name in this case will be :-</p>
<p>function getSelectedNodeValue()<br />
{<br />
var storeTemp = &#8221;;<br />
var x=document.getElementsByTagName(&#8220;td&#8221;);<br />
for(var i=0;i<br />
{<br />
var srch=x[i].innerHTML;<br />
if(srch.search(&#8216;CHECKED&#8217;)&gt;=0)<br />
{/storeTemp += x[i].innerText + &#8216;,&#8217;; }<br />
}<br />
storeTemp = storeTemp.substring(0,storeTemp.lastIndexOf(&#8216;,&#8217;));<br />
}</p>
<p>Refer to <a href="http://www.dotnetspider.com/resources/24242-how-get-value-selected-node-treeview.aspx">http://www.dotnetspider.com/resources/24242-how-get-value-selected-node-treeview.aspx</a></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/techolyvia.wordpress.com/89/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/techolyvia.wordpress.com/89/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/techolyvia.wordpress.com/89/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/techolyvia.wordpress.com/89/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/techolyvia.wordpress.com/89/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/techolyvia.wordpress.com/89/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/techolyvia.wordpress.com/89/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/techolyvia.wordpress.com/89/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/techolyvia.wordpress.com/89/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/techolyvia.wordpress.com/89/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techolyvia.wordpress.com&blog=2264071&post=89&subd=techolyvia&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://techolyvia.wordpress.com/2009/01/13/how-to-get-value-of-selected-node-in-a-treeview/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1ac0ccfaf4d6cbf2dcb01b07cbd4f3fb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">techolyvia</media:title>
		</media:content>
	</item>
		<item>
		<title>How to create files dynamically and save that in Document library.</title>
		<link>http://techolyvia.wordpress.com/2009/01/13/how-to-create-files-dynamically-and-save-that-in-document-library/</link>
		<comments>http://techolyvia.wordpress.com/2009/01/13/how-to-create-files-dynamically-and-save-that-in-document-library/#comments</comments>
		<pubDate>Tue, 13 Jan 2009 14:39:52 +0000</pubDate>
		<dc:creator>techolyvia</dc:creator>
				<category><![CDATA[Sharepoint]]></category>
		<category><![CDATA[create files on fly]]></category>
		<category><![CDATA[generate dynamic filename]]></category>
		<category><![CDATA[save file in Sharepoint document library]]></category>

		<guid isPermaLink="false">http://techolyvia.wordpress.com/?p=87</guid>
		<description><![CDATA[The other day, I was working on how to create files on the fly(dynamically create any file of any extension like .doc, .txt etc.). To do this, we will first have to provide an editor like rich text box where the user can type in something and when he saves,a dynamic file is created which [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techolyvia.wordpress.com&blog=2264071&post=87&subd=techolyvia&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>The other day, I was working on how to create files on the fly(dynamically create any file of any extension like .doc, .txt etc.). To do this, we will first have to provide an editor like rich text box where the user can type in something and when he saves,a dynamic file is created which is saved in the document library.<br />
I used a FCK editor in this case.</p>
<p>I intended to save other meta data along with the file in the document library(will talk about it later in this article).</p>
<p>        string strRTFFileName = string.Empty;<br />
        SPList ospList = null;<br />
        Hashtable metadataTable = new Hashtable();<br />
        MemoryStream mstream = new MemoryStream();<br />
        Stream stream = null;<br />
        SPWeb ospWeb = ospSite.OpenWeb();<br />
        string strReader = string.Empty;<br />
        SPWeb sourceWeb = SPContext.Current.Web;<br />
string sourceList = &#8220;Brochure&#8221;; //Name of Document library to save file.<br />
        SPList sourceListObj = sourceWeb.Lists[sourceList];</p>
<p>//Declare a streamwriter and output it&#8217;s value to memory stream<br />
        StreamWriter sw = new StreamWriter(mstream);<br />
//FCKeditor1 is name of the FCK Editor.<br />
        sw.Write(FCKeditor1.Value);<br />
// Creating file name dynamically based on datetime value</p>
<p>        strRTFFileName = string.Format(&#8220;text-{0:yyyy-MM-dd_hh-mm-ss-tt}.rtf&#8221;, DateTime.Now);<br />
            string pattern = &#8220;[^a-z0-9A-Z. ]&#8220;;<br />
            Regex objRegex = new Regex(pattern);<br />
            strRTFFileName = objRegex.Replace(strRTFFileName, &#8220;&#8221;);</p>
<p>// End of dynamic file name creation</p>
<p>// On flushing StreamWriter, value is copied to memorystream.<br />
         sw.Flush();<br />
         byte[] contents = new byte[mstream.Length];<br />
         mstream.Read(contents, 0, (int)mstream.Length);</p>
<p>        ospWeb.AllowUnsafeUpdates = true;<br />
        sourceItem = sourceWeb.Files.Add(sourceWeb.Url + &#8220;/&#8221; + sourceListObj.RootFolder.ToString() + &#8220;/&#8221; + strRTFFileName, mstream, true);<br />
        mstream.Close();<br />
        ospWeb.AllowUnsafeUpdates </p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/techolyvia.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/techolyvia.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/techolyvia.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/techolyvia.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/techolyvia.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/techolyvia.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/techolyvia.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/techolyvia.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/techolyvia.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/techolyvia.wordpress.com/87/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techolyvia.wordpress.com&blog=2264071&post=87&subd=techolyvia&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://techolyvia.wordpress.com/2009/01/13/how-to-create-files-dynamically-and-save-that-in-document-library/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1ac0ccfaf4d6cbf2dcb01b07cbd4f3fb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">techolyvia</media:title>
		</media:content>
	</item>
	</channel>
</rss>