Archive for the ‘ASP.NET’ Category


March 25, 2013

Recently me and my friend Radek Matouch  started a new company. We focus on development and consulting in SharePoint  and .NET. Check out our website if you are interested and wish us luck . 😉

The SessionId is different with every request.

July 17, 2009

This problem can because nothing was written into the session and therefore the session is forgotten with the end of the request.
What you can actually do is to save something into the session during the request and everyting should work fine.
For example:
this.Page.Session[“dummy”] = DateTime.Now;
There are also some other good recommendations and gotchas here:

Replace img link via jquery

June 25, 2009

This code will find all img tags  in the page that point to the image _layouts/images/gosearch.gif and replace it with another link.

<script src=””></script>
$(document).ready(function() {
$(“img[src*=’_layouts/images/gosearch.gif’]”).attr(‘src’, ‘_layouts/images/newicon.gif’);

$(“img[onmouseout*=’/_layouts/images/gosearch.gif’]”).attr(‘onmouseout’, “this.src=’_layouts/images/newicon.gif'”);

How to locate where a SPWebApplication or a SPSite is stored on the file system

March 11, 2009

private string GetLocalPathOfWebApplication(SPWebApplication webApplication)
string iisConnectionString = “IIS://localhost/W3SVC”;
DirectoryEntry iis = new DirectoryEntry(iisConnectionString);
foreach (DirectoryEntry child in iis.Children)
//filtering web sites
if (child.SchemaClassName == “IIsWebServer”)
DirectoryEntry site = new DirectoryEntry(iisConnectionString + “/” + child.Name);
//comparing web sites names in iis with name of SPWebApplication
if (string.Compare(webApplication.Name, site.Properties[“ServerComment”].Value.ToString(), true) == 0)
//getting local path of the web site
DirectoryEntry virtualDir = new DirectoryEntry(iisConnectionString + “/” + id + “/Root”);
return virtualDir.Properties[“Path”].Value.ToString();
return string.Empty;

Useful for example if you want to backup web.config of the application before you make any changes to it.