<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>My DasBlog! - C#</title>
    <link>http://net.bloggix.com/</link>
    <description>newtelligence powered</description>
    <language>en-us</language>
    <copyright>Alexander Meijers</copyright>
    <lastBuildDate>Mon, 05 Dec 2005 13:09:45 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.3.9074.18820</generator>
    <managingEditor>a.meijers@smoothocean.com</managingEditor>
    <webMaster>a.meijers@smoothocean.com</webMaster>
    <item>
      <trackback:ping>http://net.bloggix.com/Trackback.aspx?guid=1c1b2171-34fd-4559-a903-eea25a85320e</trackback:ping>
      <pingback:server>http://net.bloggix.com/pingback.aspx</pingback:server>
      <pingback:target>http://net.bloggix.com/PermaLink,guid,1c1b2171-34fd-4559-a903-eea25a85320e.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://net.bloggix.com/CommentView,guid,1c1b2171-34fd-4559-a903-eea25a85320e.aspx</wfw:comment>
      <wfw:commentRss>http://net.bloggix.com/SyndicationService.asmx/GetEntryCommentsRss?guid=1c1b2171-34fd-4559-a903-eea25a85320e</wfw:commentRss>
      <slash:comments>5</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <font color="#000000">I always forget the exact order in which events fire. So i found
the following when i googled and wanna share it with you all :) </font>
          <font color="#000000">
            <br />
            <br />
            <strong>
              <em>Page.Init + Control.Init for every control on the Web Form</em>
            </strong>
            <br />
          </font>
          <font color="#000000">The first stage in the page life cycle is initialization.
After the page's control tree is populated with all the statically declared controls
in the .aspx source the Init event is fired. First, the Init event for the Page object
occurs, then Init event occurs for each control on the Page. Viewstate information
is not available at this stage. 
<br /><br /><em><strong>Page.LoadViewState</strong></em><br />
After initialization, ASP.NET loads the view state for the page. ViewState contains
the state of the controls the last time the page was processed on the server. 
<br /><br /><strong><em>Page.ProcessPostData</em></strong><br />
Post Data gets read from the request and control values are applied to control initalized
in stage 1. 
<br /><br /><strong><em>Page.Load + Control.Load for each control on the Page<br /></em></strong>If this is the first time the page is being processed (Page.IsPostback
property), initial data binding is performed here. 
<br /><br /><em><strong>"Change" events are fired for controls</strong></em><br />
(TextChanged, SelectedIndexChanged, and similar) The current value (from Post Data)
is compared to the original value located in the ViewState. If there is a difference
"Changed" events are raised. 
<br /><br /><strong><em>Server-side events are fired for any validation controls</em></strong><br />
Button.Click + Button.Command<br />
The Click and Command events are fired for the button that caused the postback 
<br /><br /><strong><em>Page.PreRender + Control.PreRender 
<br /></em></strong><br /><strong><em>Page.SaveViewState<br /></em></strong>New values for all the controls are saved to the view state for another
round-trip to the server. 
<br /><br /><em><strong>Page.Render</strong></em></font>
        </p>
        <img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=1c1b2171-34fd-4559-a903-eea25a85320e" />
      </body>
      <title>Postback Event Processing Sequence</title>
      <guid isPermaLink="false">http://net.bloggix.com/PermaLink,guid,1c1b2171-34fd-4559-a903-eea25a85320e.aspx</guid>
      <link>http://net.bloggix.com/2005/12/05/PostbackEventProcessingSequence.aspx</link>
      <pubDate>Mon, 05 Dec 2005 13:09:45 GMT</pubDate>
      <description>&lt;p&gt;
&lt;font color=#000000&gt;I always forget the exact order in which events fire. So i found
the following when i googled and wanna share it with you all :) &lt;/font&gt;&lt;font color=#000000&gt;
&lt;br&gt;
&lt;br&gt;
&lt;strong&gt;&lt;em&gt;Page.Init + Control.Init for every control on the Web Form&lt;/em&gt;&lt;/strong&gt;
&lt;br&gt;
&lt;/font&gt;&lt;font color=#000000&gt;The first stage in the page life cycle is initialization.
After the page's control tree is populated with all the statically declared controls
in the .aspx source the Init event is fired. First, the Init event for the Page object
occurs, then Init event occurs for each control on the Page. Viewstate information
is not available at this stage. 
&lt;br&gt;
&lt;br&gt;
&lt;em&gt;&lt;strong&gt;Page.LoadViewState&lt;/strong&gt;&lt;/em&gt;
&lt;br&gt;
After initialization, ASP.NET loads the view state for the page. ViewState contains
the state of the controls the last time the page was processed on the server. 
&lt;br&gt;
&lt;br&gt;
&lt;strong&gt;&lt;em&gt;Page.ProcessPostData&lt;/em&gt;&lt;/strong&gt;
&lt;br&gt;
Post Data gets read from the request and control values are applied to control initalized
in stage 1. 
&lt;br&gt;
&lt;br&gt;
&lt;strong&gt;&lt;em&gt;Page.Load + Control.Load for each control on the Page&lt;br&gt;
&lt;/em&gt;&lt;/strong&gt;If this is the first time the page is being processed (Page.IsPostback
property), initial data binding is performed here. 
&lt;br&gt;
&lt;br&gt;
&lt;em&gt;&lt;strong&gt;"Change" events are fired for controls&lt;/strong&gt;&lt;/em&gt; 
&lt;br&gt;
(TextChanged, SelectedIndexChanged, and similar) The current value (from Post Data)
is compared to the original value located in the ViewState. If there is a difference
"Changed" events are raised. 
&lt;br&gt;
&lt;br&gt;
&lt;strong&gt;&lt;em&gt;Server-side events are fired for any validation controls&lt;/em&gt;&lt;/strong&gt; 
&lt;br&gt;
Button.Click + Button.Command&lt;br&gt;
The Click and Command events are fired for the button that caused the postback 
&lt;br&gt;
&lt;br&gt;
&lt;strong&gt;&lt;em&gt;Page.PreRender + Control.PreRender 
&lt;br&gt;
&lt;/em&gt;&lt;/strong&gt;
&lt;br&gt;
&lt;strong&gt;&lt;em&gt;Page.SaveViewState&lt;br&gt;
&lt;/em&gt;&lt;/strong&gt;New values for all the controls are saved to the view state for another
round-trip to the server. 
&lt;br&gt;
&lt;br&gt;
&lt;em&gt;&lt;strong&gt;Page.Render&lt;/strong&gt;&lt;/em&gt; &lt;/font&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=1c1b2171-34fd-4559-a903-eea25a85320e" /&gt;</description>
      <comments>http://net.bloggix.com/CommentView,guid,1c1b2171-34fd-4559-a903-eea25a85320e.aspx</comments>
      <category>ASP.NET</category>
      <category>C#</category>
    </item>
    <item>
      <trackback:ping>http://net.bloggix.com/Trackback.aspx?guid=0f35344d-d075-4647-960a-56422313c24e</trackback:ping>
      <pingback:server>http://net.bloggix.com/pingback.aspx</pingback:server>
      <pingback:target>http://net.bloggix.com/PermaLink,guid,0f35344d-d075-4647-960a-56422313c24e.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://net.bloggix.com/CommentView,guid,0f35344d-d075-4647-960a-56422313c24e.aspx</wfw:comment>
      <wfw:commentRss>http://net.bloggix.com/SyndicationService.asmx/GetEntryCommentsRss?guid=0f35344d-d075-4647-960a-56422313c24e</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://mindsharpblogs.com/todd/">
            <font color="#000000">Todd</font>
          </a>
          <font color="#000000"> wrote
a nice article about showing styles when moving your cursor around. A lot of people
asked him how to alter elements of WSS WebPart Pages. He gives a good walk-through
and some code. Thanks Todd :)</font>
        </p>
        <p>
          <a href="http://mindsharpblogs.com/todd/archive/2005/10/25/798.aspx">
            <font color="#000000">http://mindsharpblogs.com/todd/archive/2005/10/25/798.aspx</font>
          </a>
        </p>
        <img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=0f35344d-d075-4647-960a-56422313c24e" />
      </body>
      <title>Style Under Cursor CEWP by Todd Bleeker</title>
      <guid isPermaLink="false">http://net.bloggix.com/PermaLink,guid,0f35344d-d075-4647-960a-56422313c24e.aspx</guid>
      <link>http://net.bloggix.com/2005/10/26/StyleUnderCursorCEWPByToddBleeker.aspx</link>
      <pubDate>Wed, 26 Oct 2005 06:26:50 GMT</pubDate>
      <description>&lt;p&gt;
&lt;a href="http://mindsharpblogs.com/todd/"&gt;&lt;font color=#000000&gt;Todd&lt;/font&gt;&lt;/a&gt;&lt;font color=#000000&gt; wrote
a nice article about showing styles when moving your cursor around. A lot of people
asked him how to alter elements of WSS WebPart Pages. He gives a good walk-through
and some code. Thanks Todd :)&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://mindsharpblogs.com/todd/archive/2005/10/25/798.aspx"&gt;&lt;font color=#000000&gt;http://mindsharpblogs.com/todd/archive/2005/10/25/798.aspx&lt;/font&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=0f35344d-d075-4647-960a-56422313c24e" /&gt;</description>
      <comments>http://net.bloggix.com/CommentView,guid,0f35344d-d075-4647-960a-56422313c24e.aspx</comments>
      <category>C#</category>
      <category>SharePoint</category>
    </item>
    <item>
      <trackback:ping>http://net.bloggix.com/Trackback.aspx?guid=a1c2053d-9469-401e-895c-20cbd11eae01</trackback:ping>
      <pingback:server>http://net.bloggix.com/pingback.aspx</pingback:server>
      <pingback:target>http://net.bloggix.com/PermaLink,guid,a1c2053d-9469-401e-895c-20cbd11eae01.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://net.bloggix.com/CommentView,guid,a1c2053d-9469-401e-895c-20cbd11eae01.aspx</wfw:comment>
      <wfw:commentRss>http://net.bloggix.com/SyndicationService.asmx/GetEntryCommentsRss?guid=a1c2053d-9469-401e-895c-20cbd11eae01</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <font color="#000000">The SPWebCollection returned by the member <font face="Courier New" color="#808080">SPWeb.Webs</font> is
a not sorted list of <font face="Courier New" color="#808080">SPWeb</font> objects.
So i wrote a class which makes it possible to return a sorted list of <font face="Courier New" color="#808080">SPWeb</font> objects
based on the property of a <font face="Courier New" color="#808080">SPWeb</font>.
It is basically very simple and uses some standard .NET interfaces for enumerating
and comparing.</font>
        </p>
        <p>
          <font face="Courier New" color="#808080">public class SPSortedWebCollection : IEnumerable,
IEnumerator<br />
{<br />
   private ArrayList list = new ArrayList();<br />
   private int index = -1;<br />
   private string property = "";</font>
        </p>
        <p>
          <font color="#000000">The constructor of the class needs a name of the property and
the original collection of <font face="Courier New" color="#808080">SPWeb</font> objects
returned by for example the <font face="Courier New" color="#808080">SPWeb.Webs</font> member.
It adds the <font face="Courier New" color="#808080">SPWeb</font> objects and initializes
the class.</font>
        </p>
        <p>
          <font face="Courier New" color="#808080">   public SPSortedWebCollection(SPWebCollection
webs, string property)<br />
   {<br />
      this.property = property;<br /></font>
          <font face="Courier New" color="#808080">
            <br />
      foreach(SPWeb child in webs)<br />
      {<br />
         Add(child);<br />
      }</font>
        </p>
        <p>
          <font face="Courier New" color="#808080">      Reset();<br />
   }</font>
        </p>
        <p>
          <font face="Courier New" color="#808080">
            <font face="Verdana" color="#000000">This
method can be used to add some additional <font face="Courier New" color="#808080">SPWeb</font> objects.
Don't forget to call the <font face="Courier New" color="#808080">Reset()</font> member
for resetting and sorting the collection again.</font>
          </font>
        </p>
        <font face="Courier New" color="#808080">
          <font face="Verdana" color="#000000">
          </font>
          <p>
            <br />
          </p>
        </font>
        <font face="Courier New" color="#808080">   public void
Add(SPWeb web)<br />
   {<br />
      list.Add(new SPSortedWeb(web, property));<br />
   }</font>
        <p>
          <font color="#000000">Inside the class another class is found which stores the <font face="Courier New" color="#808080">SPWeb</font> objects.
It uses the <font face="Courier New" color="#808080">IComparable</font> interface
for comparing itself against another instance of <font face="Courier New" color="#808080">SPSortedWeb</font>.
The Sort member of the <font face="Courier New" color="#808080">ArrayList</font> automatically
uses the <font face="Courier New" color="#808080">CompareTo</font> member of the interface
when sorting the list.</font>
        </p>
        <p>
          <font face="Courier New" color="#808080">   protected class SPSortedWeb
: IComparable<br />
   {<br />
      private SPWeb web = null;<br />
      private string property = "";</font>
        </p>
        <p>
          <font face="Courier New" color="#808080">      public
SPSortedWeb(SPWeb web, string property)<br />
      {<br />
         this.web = web;<br />
         this.property = property;<br />
      }</font>
        </p>
        <p>
          <font face="Courier New" color="#808080">      public
SPWeb Web<br />
      {<br />
         get<br />
         {<br />
            return web;<br />
         }<br />
      }</font>
        </p>
        <p>
          <font face="Courier New" color="#808080">      public
int CompareTo(object obj)<br />
      {<br />
         SPSortedWeb sw = obj as SPSortedWeb;</font>
        </p>
        <p>
          <font face="Courier New" color="#808080">         string
val = SharePointHelper.GetPropertyCode(web, property);<br />
         string compareToVal = SharePointHelper.GetPropertyCode(sw.Web,
property);</font>
        </p>
        <p>
          <font face="Courier New" color="#808080">         return
val.CompareTo(compareToVal);<br />
      }<br />
   }</font>
        </p>
        <p>
          <font color="#000000">Finally the class is given some methods for enumerating through
the list. You can use easily the <font face="Courier New" color="#808080">foreach(...)</font> loop
to retrieve the <font face="Courier New" color="#808080">SPWeb</font> objects.</font>
        </p>
        <p>
          <font face="Courier New" color="#808080">   public IEnumerator GetEnumerator()<br />
   {<br />
      return this;<br />
   }</font>
        </p>
        <p>
          <font face="Courier New" color="#808080">   public void Reset()<br />
   {<br />
      list.Sort();<br />
      index = -1;<br />
   }</font>
        </p>
        <p>
          <font face="Courier New" color="#808080">   public object Current<br />
   {<br />
      get<br />
      {<br />
         SPSortedWeb sw = (index &lt;
0 || index &gt;= list.Count) ? null : list[index] as SPSortedWeb;<br />
    <br />
         return sw != null ? sw.Web :
null;<br />
      }<br />
   }</font>
        </p>
        <p>
          <font face="Courier New" color="#808080">   public bool MoveNext()<br />
   {<br />
      index++;</font>
        </p>
        <p>
          <font face="Courier New" color="#808080">      return
index &lt; list.Count;<br />
   }<br />
}</font>
        </p>
        <p>
          <font color="#000000">For retrieving the property of a <font face="Courier New" color="#808080">SPWeb</font> object
the following class is used:</font>
        </p>
        <p>
          <font face="Courier New" color="#808080">public class SharePointHelper<br />
{  <br />
   </font>
          <font face="Courier New" color="#808080">public static string
GetPropertyCode(SPWeb web, string property)<br />
   {<br />
      if (web.Properties.ContainsKey(property))<br />
      {<br />
         return web.Properties[property];<br />
      }</font>
        </p>
        <p>
          <font face="Courier New" color="#808080">      return
"";<br />
   }<br />
}</font>
        </p>
        <p>
          <font color="#000000">To use the class the following example gives you some idea of
how it works:</font>
        </p>
        <p>
          <font face="Courier New" color="#808080">SPSortedWebCollection col = new SPSortedWebCollection(currentWeb.Webs,
"Number");</font>
        </p>
        <p>
          <font face="Courier New" color="#808080">foreach(SPWeb child in col)<br />
{<br />
...</font>
          <font face="Courier New" color="#808080">
            <br />
}</font>
        </p>
        <img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=a1c2053d-9469-401e-895c-20cbd11eae01" />
      </body>
      <title>Sort your SPWebCollection based on a property of the SPWeb</title>
      <guid isPermaLink="false">http://net.bloggix.com/PermaLink,guid,a1c2053d-9469-401e-895c-20cbd11eae01.aspx</guid>
      <link>http://net.bloggix.com/2005/08/15/SortYourSPWebCollectionBasedOnAPropertyOfTheSPWeb.aspx</link>
      <pubDate>Mon, 15 Aug 2005 09:05:09 GMT</pubDate>
      <description>&lt;p&gt;
&lt;font color=#000000&gt;The SPWebCollection returned by the member &lt;font face="Courier New" color=#808080&gt;SPWeb.Webs&lt;/font&gt; is
a not sorted list of &lt;font face="Courier New" color=#808080&gt;SPWeb&lt;/font&gt; objects.
So i wrote a class which makes it possible to return a sorted list of &lt;font face="Courier New" color=#808080&gt;SPWeb&lt;/font&gt; objects
based on the property of a &lt;font face="Courier New" color=#808080&gt;SPWeb&lt;/font&gt;. It
is basically very simple and uses some standard .NET interfaces for enumerating and
comparing.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;public class SPSortedWebCollection : IEnumerable,
IEnumerator&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;private ArrayList list = new ArrayList();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;private int index = -1;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;private string property = "";&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;The constructor of the class needs a name of the property and
the original collection of &lt;font face="Courier New" color=#808080&gt;SPWeb&lt;/font&gt; objects
returned by for example the &lt;font face="Courier New" color=#808080&gt;SPWeb.Webs&lt;/font&gt; member.
It adds the &lt;font face="Courier New" color=#808080&gt;SPWeb&lt;/font&gt; objects and initializes
the class.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;public SPSortedWebCollection(SPWebCollection
webs, string property)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;this.property = property;&lt;br&gt;
&lt;/font&gt;&lt;font face="Courier New" color=#808080&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;foreach(SPWeb child in webs)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Add(child);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Reset();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;&lt;font face=Verdana color=#000000&gt;This method
can be used to add some additional &lt;font face="Courier New" color=#808080&gt;SPWeb&lt;/font&gt; objects.
Don't forget to call the &lt;font face="Courier New" color=#808080&gt;Reset()&lt;/font&gt; member
for&amp;nbsp;resetting and sorting the collection again.&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;font face="Courier New" color=#808080&gt;&lt;font face=Verdana color=#000000&gt;&lt;/font&gt; 
&lt;p&gt;
&lt;br&gt;
&lt;/font&gt;&lt;font face="Courier New" color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;public void Add(SPWeb
web)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;list.Add(new SPSortedWeb(web, property));&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/font&gt;&gt;
&lt;p&gt;
&lt;font color=#000000&gt;Inside the class another class is found which stores the &lt;font face="Courier New" color=#808080&gt;SPWeb&lt;/font&gt; objects.
It uses the &lt;font face="Courier New" color=#808080&gt;IComparable&lt;/font&gt; interface for
comparing itself against another instance of &lt;font face="Courier New" color=#808080&gt;SPSortedWeb&lt;/font&gt;.
The Sort member of the &lt;font face="Courier New" color=#808080&gt;ArrayList&lt;/font&gt; automatically
uses the &lt;font face="Courier New" color=#808080&gt;CompareTo&lt;/font&gt; member of the interface
when sorting the list.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;protected class SPSortedWeb
: IComparable&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;private SPWeb web = null;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;private string property = "";&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public
SPSortedWeb(SPWeb web, string property)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;this.web = web;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;this.property = property;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public
SPWeb Web&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;get&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return web;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public
int CompareTo(object obj)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;SPSortedWeb sw = obj as SPSortedWeb;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;string
val = SharePointHelper.GetPropertyCode(web, property);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;string compareToVal = SharePointHelper.GetPropertyCode(sw.Web,
property);&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return
val.CompareTo(compareToVal);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;Finally the class is given some methods for enumerating through
the list. You can use easily the &lt;font face="Courier New" color=#808080&gt;foreach(...)&lt;/font&gt; loop
to retrieve the &lt;font face="Courier New" color=#808080&gt;SPWeb&lt;/font&gt; objects.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;public IEnumerator GetEnumerator()&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return this;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;public void Reset()&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;list.Sort();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;index = -1;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;public object Current&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;get&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;SPSortedWeb sw = (index &amp;lt;
0 || index &amp;gt;= list.Count) ? null : list[index] as SPSortedWeb;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return sw != null ? sw.Web :
null;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;public bool MoveNext()&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;index++;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return
index &amp;lt; list.Count;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;For retrieving the property of a &lt;font face="Courier New" color=#808080&gt;SPWeb&lt;/font&gt; object
the following class is used:&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;public class SharePointHelper&lt;br&gt;
{&amp;nbsp;&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font face="Courier New" color=#808080&gt;public static string
GetPropertyCode(SPWeb web, string property)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if (web.Properties.ContainsKey(property))&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return web.Properties[property];&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return
"";&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;To use the class the following example gives you some idea of
how it works:&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;SPSortedWebCollection col = new SPSortedWebCollection(currentWeb.Webs,
"Number");&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;foreach(SPWeb child in col)&lt;br&gt;
{&lt;br&gt;
...&lt;/font&gt;&lt;font face="Courier New" color=#808080&gt;
&lt;br&gt;
}&lt;/font&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=a1c2053d-9469-401e-895c-20cbd11eae01" /&gt;</description>
      <comments>http://net.bloggix.com/CommentView,guid,a1c2053d-9469-401e-895c-20cbd11eae01.aspx</comments>
      <category>C#</category>
      <category>SharePoint</category>
    </item>
    <item>
      <trackback:ping>http://net.bloggix.com/Trackback.aspx?guid=7aa4fa20-4209-4308-81af-7a68aa6e62f6</trackback:ping>
      <pingback:server>http://net.bloggix.com/pingback.aspx</pingback:server>
      <pingback:target>http://net.bloggix.com/PermaLink,guid,7aa4fa20-4209-4308-81af-7a68aa6e62f6.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://net.bloggix.com/CommentView,guid,7aa4fa20-4209-4308-81af-7a68aa6e62f6.aspx</wfw:comment>
      <wfw:commentRss>http://net.bloggix.com/SyndicationService.asmx/GetEntryCommentsRss?guid=7aa4fa20-4209-4308-81af-7a68aa6e62f6</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <font color="#000000">
            <a href="http://blogs.msdn.com/modonovan/default.aspx">
              <font color="#000000">Modonovan</font>
            </a> posted
an article which explains how to use the <font face="Courier New" color="#808080">IRuntimeFilter</font> to
hide or show WebParts in the Portal. as stated in the article:</font>
        </p>
        <p>
          <font color="#000000">
            <em>"By implementing IRuntimeFilter you are essentially creating
a rule or a set of rules that determine if a web part should be displayed or not.
For example:</em>
          </font>
        </p>
        <ul>
          <li>
            <font color="#000000">
              <em>SharePoint Portal Server (SPS) uses a <font face="Courier New" color="#808080">IRuntimeFilter</font> for
audiences. A user will setup the audiences that are allowed to see a web part (using
the advanced section in the web part’s toolpane), then when a user visits the web
page the filter runs and determines if the web part should be shown or not. If a virtual
server is extended with SPS then the <font face="Courier New" color="#808080">Microsoft.SharePoint.Portal.Audience.AudienceManager</font> filter
is installed by default. 
<br /></em>
            </font>
          </li>
          <li>
            <font color="#000000">
              <em>You could create a custom <font face="Courier New" color="#808080">IRuntimeFilter</font> that
determines if a web part should be displayed based on the WSS role the user is a member
of. This is what the sample code in this document does 
<br /></em>
            </font>
          </li>
          <li>
            <font color="#000000">
              <em>You could create a custom <font face="Courier New" color="#808080">IRuntimeFilter</font> that
determines if a web part should be displayed based on any arbitrary property or rule(s)
that you come up with."</em>
            </font>
          </li>
        </ul>
        <p>
          <font color="#000000">I often use some kind of check in my code behind to find out
which roles the current user has and then based on the information i show or hide
the WebPart. This solution presented by Modonovan is far better. :) Thanks!!</font>
        </p>
        <p>
          <a href="http://blogs.msdn.com/modonovan/archive/2005/07/07/436394.aspx">
            <font color="#000000">http://blogs.msdn.com/modonovan/archive/2005/07/07/436394.aspx</font>
          </a>
        </p>
        <img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=7aa4fa20-4209-4308-81af-7a68aa6e62f6" />
      </body>
      <title>Show and Hide WebParts using an IRuntimeFilter by Modonovan</title>
      <guid isPermaLink="false">http://net.bloggix.com/PermaLink,guid,7aa4fa20-4209-4308-81af-7a68aa6e62f6.aspx</guid>
      <link>http://net.bloggix.com/2005/07/25/ShowAndHideWebPartsUsingAnIRuntimeFilterByModonovan.aspx</link>
      <pubDate>Mon, 25 Jul 2005 13:39:41 GMT</pubDate>
      <description>&lt;p&gt;
&lt;font color=#000000&gt;&lt;a href="http://blogs.msdn.com/modonovan/default.aspx"&gt;&lt;font color=#000000&gt;Modonovan&lt;/font&gt;&lt;/a&gt; posted
an article which explains how to use the &lt;font face="Courier New" color=#808080&gt;IRuntimeFilter&lt;/font&gt; to
hide or show WebParts in the Portal. as stated in the article:&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;&lt;em&gt;"By implementing IRuntimeFilter you are essentially creating
a rule or a set of rules that determine if a web part should be displayed or not.
For example:&lt;/em&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;font color=#000000&gt;&lt;em&gt;SharePoint Portal Server (SPS) uses a &lt;font face="Courier New" color=#808080&gt;IRuntimeFilter&lt;/font&gt; for
audiences. A user will setup the audiences that are allowed to see a web part (using
the advanced section in the web part’s toolpane), then when a user visits the web
page the filter runs and determines if the web part should be shown or not. If a virtual
server is extended with SPS then the &lt;font face="Courier New" color=#808080&gt;Microsoft.SharePoint.Portal.Audience.AudienceManager&lt;/font&gt; filter
is installed by default. 
&lt;br&gt;
&lt;/em&gt;&lt;/font&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;font color=#000000&gt;&lt;em&gt;You could create a custom &lt;font face="Courier New" color=#808080&gt;IRuntimeFilter&lt;/font&gt; that
determines if a web part should be displayed based on the WSS role the user is a member
of. This is what the sample code in this document does 
&lt;br&gt;
&lt;/em&gt;&lt;/font&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;font color=#000000&gt;&lt;em&gt;You could create a custom &lt;font face="Courier New" color=#808080&gt;IRuntimeFilter&lt;/font&gt; that
determines if a web part should be displayed based on any arbitrary property or rule(s)
that you come up with."&lt;/em&gt;&lt;/font&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
&lt;font color=#000000&gt;I often use some kind of check in my code behind to find out which
roles the current user has and then based on the information i show or hide the WebPart.
This solution presented by Modonovan is far better. :) Thanks!!&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blogs.msdn.com/modonovan/archive/2005/07/07/436394.aspx"&gt;&lt;font color=#000000&gt;http://blogs.msdn.com/modonovan/archive/2005/07/07/436394.aspx&lt;/font&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=7aa4fa20-4209-4308-81af-7a68aa6e62f6" /&gt;</description>
      <comments>http://net.bloggix.com/CommentView,guid,7aa4fa20-4209-4308-81af-7a68aa6e62f6.aspx</comments>
      <category>C#</category>
      <category>SharePoint</category>
    </item>
    <item>
      <trackback:ping>http://net.bloggix.com/Trackback.aspx?guid=0dbe56f2-86e7-406f-bf98-60e7fbe19f91</trackback:ping>
      <pingback:server>http://net.bloggix.com/pingback.aspx</pingback:server>
      <pingback:target>http://net.bloggix.com/PermaLink,guid,0dbe56f2-86e7-406f-bf98-60e7fbe19f91.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://net.bloggix.com/CommentView,guid,0dbe56f2-86e7-406f-bf98-60e7fbe19f91.aspx</wfw:comment>
      <wfw:commentRss>http://net.bloggix.com/SyndicationService.asmx/GetEntryCommentsRss?guid=0dbe56f2-86e7-406f-bf98-60e7fbe19f91</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <font color="#000000">
            <a href="http://blogs.tamtam.nl/mart">
              <font color="#000000">Mart
Muller</font>
            </a> did a great post about adding a reply programmatically to a discussion
board. Just like my last post about programmatically adding history to an issue in
an issue list also this is not described clearly in the documentation of SharePoint.
The following code is used:</font>
        </p>
        <p>
          <font face="Courier New" color="#808080">SPListItem newItem = discussionList.Items.Add();<br />
newItem["Title"] = "Title of item";<br />
newItem["Body"] = "Body Text";<br />
newItem["ThreadID"] = [ThreadID of original thread];<br />
newItem["Ordering"] = [Ordering of original thread] + DateTime.Now.ToString("yyyyMMddhhmmss");<br />
newItem.Update();</font>
        </p>
        <p>
          <font color="#000000">Mart's article:</font>
        </p>
        <p>
          <a href="http://blogs.tamtam.nl/mart/SharePointTipAddingADiscussionReplyItemInAThreadProgramatically.aspx">
            <font color="#000000">http://blogs.tamtam.nl/mart/SharePointTipAdding<br />
ADiscussionReplyItemInAThreadProgramatically.aspx</font>
          </a>
        </p>
        <p>
          <font color="#000000">Article about adding history to an issue in an issue list:</font>
        </p>
        <p>
          <a href="http://net.bloggix.com/PermaLink,guid,aa4c6b98-2039-432b-af80-b8baf901fdf2.aspx">
            <font color="#000000">http://net.bloggix.com/PermaLink,guid,aa4c6b98-2039-432b-af80-b8baf901fdf2.aspx</font>
          </a>
        </p>
        <br />
        <img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=0dbe56f2-86e7-406f-bf98-60e7fbe19f91" />
      </body>
      <title>How to: Adding a discussion reply item in a thread programmatically </title>
      <guid isPermaLink="false">http://net.bloggix.com/PermaLink,guid,0dbe56f2-86e7-406f-bf98-60e7fbe19f91.aspx</guid>
      <link>http://net.bloggix.com/2005/07/21/HowToAddingADiscussionReplyItemInAThreadProgrammatically.aspx</link>
      <pubDate>Thu, 21 Jul 2005 11:42:32 GMT</pubDate>
      <description>&lt;p&gt;
&lt;font color=#000000&gt;&lt;a href="http://blogs.tamtam.nl/mart"&gt;&lt;font color=#000000&gt;Mart
Muller&lt;/font&gt;&lt;/a&gt; did a great post about adding a reply programmatically to a discussion
board. Just like my last post about programmatically adding history to an issue in
an issue list also this is not described clearly in the documentation of SharePoint.
The following code is used:&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;SPListItem newItem = discussionList.Items.Add();&lt;br&gt;
newItem["Title"] = "Title of item";&lt;br&gt;
newItem["Body"] = "Body Text";&lt;br&gt;
newItem["ThreadID"] = [ThreadID of original thread];&lt;br&gt;
newItem["Ordering"] = [Ordering of original thread] + DateTime.Now.ToString("yyyyMMddhhmmss");&lt;br&gt;
newItem.Update();&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;Mart's article:&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blogs.tamtam.nl/mart/SharePointTipAddingADiscussionReplyItemInAThreadProgramatically.aspx"&gt;&lt;font color=#000000&gt;http://blogs.tamtam.nl/mart/SharePointTipAdding&lt;br&gt;
ADiscussionReplyItemInAThreadProgramatically.aspx&lt;/font&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;Article about adding history to an issue in an issue list:&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://net.bloggix.com/PermaLink,guid,aa4c6b98-2039-432b-af80-b8baf901fdf2.aspx"&gt;&lt;font color=#000000&gt;http://net.bloggix.com/PermaLink,guid,aa4c6b98-2039-432b-af80-b8baf901fdf2.aspx&lt;/font&gt;&lt;/a&gt;&gt;
&lt;/p&gt;
&lt;br&gt;
&lt;img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=0dbe56f2-86e7-406f-bf98-60e7fbe19f91" /&gt;</description>
      <comments>http://net.bloggix.com/CommentView,guid,0dbe56f2-86e7-406f-bf98-60e7fbe19f91.aspx</comments>
      <category>C#</category>
      <category>SharePoint</category>
    </item>
    <item>
      <trackback:ping>http://net.bloggix.com/Trackback.aspx?guid=29ff2a52-6353-4685-83a5-f5d522dc1916</trackback:ping>
      <pingback:server>http://net.bloggix.com/pingback.aspx</pingback:server>
      <pingback:target>http://net.bloggix.com/PermaLink,guid,29ff2a52-6353-4685-83a5-f5d522dc1916.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://net.bloggix.com/CommentView,guid,29ff2a52-6353-4685-83a5-f5d522dc1916.aspx</wfw:comment>
      <wfw:commentRss>http://net.bloggix.com/SyndicationService.asmx/GetEntryCommentsRss?guid=29ff2a52-6353-4685-83a5-f5d522dc1916</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <font color="#000000">If you create a WebPart containing a multiline <font face="Courier New" color="#808080">TextBox</font>,
the <font face="Courier New" color="#808080">TextBox</font> does not size automatically
with the width of the WebPart. Requesting the <font face="Courier New" color="#808080">Width</font> of
the WebPart is not an option because its not yet in the clients browser. So the following
example shows a way of sizing the <font face="Courier New" color="#808080">TextBox</font> to
100% in the WebPart. <font face="Courier New" color="#808080">tbRemark</font> is a <font face="Courier New" color="#808080">TextBox</font> with
the <font face="Courier New" color="#808080">TextMode</font> set to <font face="Courier New" color="#808080">TextBoxMode.MultiLine</font>.</font>
        </p>
        <p>
          <font face="Courier New" color="#808080">protected override void RenderWebPart(HtmlTextWriter
output)<br />
{<br />
   output.WriteLine("&lt;style&gt;.StyleRemark { width:100%;height:100;
}&lt;/style&gt;");<br /><br />
   output.WriteLine("&lt;TABLE id=\"Table1\" cellSpacing=\"1\" cellPadding=\"1\"
width=\"100%\" border=\"0\"&gt;");<br />
   output.WriteLine("&lt;TR&gt;&lt;TD&gt;");</font>
        </p>
        <p>
          <font face="Courier New" color="#808080">   tbRemark.Text = Remark;<br />
   tbRemark.CssClass = "StyleRemark";<br />
   tbRemark.RenderControl(output);<br /><br />
   output.WriteLine("&lt;/TD&gt;&lt;/TR&gt;");<br />
   output.WriteLine("&lt;/TABLE&gt;");<br />
}</font>
        </p>
        <img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=29ff2a52-6353-4685-83a5-f5d522dc1916" />
      </body>
      <title>How to: Size / Maximize a multiline TextBox in a WebPart</title>
      <guid isPermaLink="false">http://net.bloggix.com/PermaLink,guid,29ff2a52-6353-4685-83a5-f5d522dc1916.aspx</guid>
      <link>http://net.bloggix.com/2005/07/21/HowToSizeMaximizeAMultilineTextBoxInAWebPart.aspx</link>
      <pubDate>Thu, 21 Jul 2005 07:51:58 GMT</pubDate>
      <description>&lt;p&gt;
&lt;font color=#000000&gt;If you create a WebPart containing a multiline &lt;font face="Courier New" color=#808080&gt;TextBox&lt;/font&gt;,
the &lt;font face="Courier New" color=#808080&gt;TextBox&lt;/font&gt; does not size automatically
with the width of the WebPart. Requesting the &lt;font face="Courier New" color=#808080&gt;Width&lt;/font&gt; of
the WebPart is not an option because its not yet in the clients browser. So the following
example shows a way of sizing the &lt;font face="Courier New" color=#808080&gt;TextBox&lt;/font&gt; to
100% in the WebPart. &lt;font face="Courier New" color=#808080&gt;tbRemark&lt;/font&gt; is a &lt;font face="Courier New" color=#808080&gt;TextBox&lt;/font&gt; with
the &lt;font face="Courier New" color=#808080&gt;TextMode&lt;/font&gt; set to &lt;font face="Courier New" color=#808080&gt;TextBoxMode.MultiLine&lt;/font&gt;.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;protected override void RenderWebPart(HtmlTextWriter
output)&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;output.WriteLine("&amp;lt;style&amp;gt;.StyleRemark { width:100%;height:100;
}&amp;lt;/style&amp;gt;");&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;output.WriteLine("&amp;lt;TABLE id=\"Table1\" cellSpacing=\"1\" cellPadding=\"1\"
width=\"100%\" border=\"0\"&amp;gt;");&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;output.WriteLine("&amp;lt;TR&amp;gt;&amp;lt;TD&amp;gt;");&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;tbRemark.Text = Remark;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;tbRemark.CssClass = "StyleRemark";&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;tbRemark.RenderControl(output);&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;output.WriteLine("&amp;lt;/TD&amp;gt;&amp;lt;/TR&amp;gt;");&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;output.WriteLine("&amp;lt;/TABLE&amp;gt;");&lt;br&gt;
}&lt;/font&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=29ff2a52-6353-4685-83a5-f5d522dc1916" /&gt;</description>
      <comments>http://net.bloggix.com/CommentView,guid,29ff2a52-6353-4685-83a5-f5d522dc1916.aspx</comments>
      <category>C#</category>
      <category>SharePoint</category>
    </item>
    <item>
      <trackback:ping>http://net.bloggix.com/Trackback.aspx?guid=8c050f4a-6a0d-4111-9062-f1b569deb255</trackback:ping>
      <pingback:server>http://net.bloggix.com/pingback.aspx</pingback:server>
      <pingback:target>http://net.bloggix.com/PermaLink,guid,8c050f4a-6a0d-4111-9062-f1b569deb255.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://net.bloggix.com/CommentView,guid,8c050f4a-6a0d-4111-9062-f1b569deb255.aspx</wfw:comment>
      <wfw:commentRss>http://net.bloggix.com/SyndicationService.asmx/GetEntryCommentsRss?guid=8c050f4a-6a0d-4111-9062-f1b569deb255</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://blogs.tamtam.nl/paulb/default.aspx">
            <font color="#000000">Paul Brenk</font>
          </a>
          <font color="#000000"> has
posted some usefull code which shows us how to deserialize a string containing XML
to an object using a <font face="Courier New" color="#808080">StringReader</font> and
a <font face="Courier New" color="#808080">XmlTextReader</font> object. It also shows
us how it handles a XML-array using serialization attributes.</font>
        </p>
        <p>
          <a href="http://blogs.tamtam.nl/paulb/DeserializingAnXmlstringAndXmlArrays.aspx">
            <font color="#000000">http://blogs.tamtam.nl/paulb/DeserializingAnXmlstringAndXmlArrays.aspx</font>
          </a>
        </p>
        <img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=8c050f4a-6a0d-4111-9062-f1b569deb255" />
      </body>
      <title>How to: Deserializing a string containing XML and a XML-array</title>
      <guid isPermaLink="false">http://net.bloggix.com/PermaLink,guid,8c050f4a-6a0d-4111-9062-f1b569deb255.aspx</guid>
      <link>http://net.bloggix.com/2005/07/19/HowToDeserializingAStringContainingXMLAndAXMLarray.aspx</link>
      <pubDate>Tue, 19 Jul 2005 06:25:56 GMT</pubDate>
      <description>&lt;p&gt;
&lt;a href="http://blogs.tamtam.nl/paulb/default.aspx"&gt;&lt;font color=#000000&gt;Paul Brenk&lt;/font&gt;&lt;/a&gt;&lt;font color=#000000&gt; has
posted some usefull code which shows us how to deserialize a string containing XML
to an object using a &lt;font face="Courier New" color=#808080&gt;StringReader&lt;/font&gt; and
a &lt;font face="Courier New" color=#808080&gt;XmlTextReader&lt;/font&gt; object. It also shows
us how it handles a XML-array using serialization attributes.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blogs.tamtam.nl/paulb/DeserializingAnXmlstringAndXmlArrays.aspx"&gt;&lt;font color=#000000&gt;http://blogs.tamtam.nl/paulb/DeserializingAnXmlstringAndXmlArrays.aspx&lt;/font&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=8c050f4a-6a0d-4111-9062-f1b569deb255" /&gt;</description>
      <comments>http://net.bloggix.com/CommentView,guid,8c050f4a-6a0d-4111-9062-f1b569deb255.aspx</comments>
      <category>C#</category>
    </item>
    <item>
      <trackback:ping>http://net.bloggix.com/Trackback.aspx?guid=e1b1d457-4422-4d0d-8b9e-52eceba916ce</trackback:ping>
      <pingback:server>http://net.bloggix.com/pingback.aspx</pingback:server>
      <pingback:target>http://net.bloggix.com/PermaLink,guid,e1b1d457-4422-4d0d-8b9e-52eceba916ce.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://net.bloggix.com/CommentView,guid,e1b1d457-4422-4d0d-8b9e-52eceba916ce.aspx</wfw:comment>
      <wfw:commentRss>http://net.bloggix.com/SyndicationService.asmx/GetEntryCommentsRss?guid=e1b1d457-4422-4d0d-8b9e-52eceba916ce</wfw:commentRss>
      <slash:comments>9</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <font color="#000000">Microsoft has a nice collection of controls bundled into a package
called "IE Web Controls". Except for the fact that they are fully unsupported some
controls are very handy.</font>
        </p>
        <p>
          <font color="#000000">
            <img src="http://net.bloggix.com/content/binary/metadata.JPG" border="0" />
          </font>
        </p>
        <p>
          <font color="#000000">I have used the <font face="Courier New" color="#808080">TreeView</font> in
a custom WebPart and had some difficulty setting the styles. It seems you have to
set the styles <font face="Courier New" color="#808080">DefaultStyle</font>, <font face="Courier New" color="#808080">HoverStyle</font> and <font face="Courier New" color="#808080">SelectedStyle</font>.
The <font face="Courier New" color="#808080">DefaultStyle</font> is used when no action
takes place, the <font face="Courier New" color="#808080">HoverStyle</font> is set
when you hover with your mouse over an item and the <font face="Courier New" color="#808080">SelectedStyle</font> is
the style of a selected item. Here are two examples of setting the style in a <font face="Courier New" color="#808080">TreeView</font>.</font>
        </p>
        <p>
          <font face="Courier New" color="#808080">&lt;mytree:treeview runat="server" <br />
   </font>
          <font face="Courier New" color="#808080">ID="tvwResources" <br />
   <strong>defaultStyle</strong>="font-family:Verdana,Arial,Sans-serif;color:#000000;font-size:11px;" <br />
   <strong>hoverStyle</strong>="font-family:Verdana,Arial,Sans-serif;color:#000000;font-size:11px;" <br />
   <strong>selectedStyle</strong>="font-family:Verdana,Arial,Sans-serif;color:#000000;font-size:11px;&gt;<br />
&lt;/mytree:treeview&gt;</font>
        </p>
        <p>
          <font color="#000000">Or programmatically</font>
        </p>
        <p>
          <font face="Courier New" color="#808080">mytree.DefaultStyle["font-family"] = "Verdana,Arial,Sans-serif";<br />
mytree.DefaultStyle["color"] = "#000000";<br />
mytree.DefaultStyle["font-size"] = "11px";</font>
        </p>
        <p>
          <font face="Courier New" color="#808080">mytree.HoverStyle["font-family"] = "Verdana,Arial,Sans-serif";<br />
mytree.HoverStyle["color"] = "#000000";<br />
mytree.HoverStyle["font-size"] = "11px";</font>
        </p>
        <p>
          <font face="Courier New" color="#808080">mytree.SelectedStyle["font-family"] = "Verdana,Arial,Sans-serif";<br />
mytree.SelectedStyle["color"] = "#000000";<br />
mytree.SelectedStyle["font-size"] = "11px";</font>
        </p>
        <img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=e1b1d457-4422-4d0d-8b9e-52eceba916ce" />
      </body>
      <title>How to: Set the style in a TreeView of the IE Web Controls</title>
      <guid isPermaLink="false">http://net.bloggix.com/PermaLink,guid,e1b1d457-4422-4d0d-8b9e-52eceba916ce.aspx</guid>
      <link>http://net.bloggix.com/2005/07/13/HowToSetTheStyleInATreeViewOfTheIEWebControls.aspx</link>
      <pubDate>Wed, 13 Jul 2005 06:39:05 GMT</pubDate>
      <description>&lt;p&gt;
&lt;font color=#000000&gt;Microsoft has a nice collection of controls bundled into a package
called "IE Web Controls". Except for the fact that they are fully unsupported some
controls are very handy.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;&lt;img src="http://net.bloggix.com/content/binary/metadata.JPG" border=0&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;I have used the &lt;font face="Courier New" color=#808080&gt;TreeView&lt;/font&gt; in
a custom WebPart and had some difficulty setting the styles. It seems you have to
set the styles &lt;font face="Courier New" color=#808080&gt;DefaultStyle&lt;/font&gt;, &lt;font face="Courier New" color=#808080&gt;HoverStyle&lt;/font&gt; and &lt;font face="Courier New" color=#808080&gt;SelectedStyle&lt;/font&gt;.
The &lt;font face="Courier New" color=#808080&gt;DefaultStyle&lt;/font&gt; is used when no action
takes place, the &lt;font face="Courier New" color=#808080&gt;HoverStyle&lt;/font&gt; is set when
you hover with your mouse over an item and the &lt;font face="Courier New" color=#808080&gt;SelectedStyle&lt;/font&gt; is
the style of a selected item. Here are two examples of setting the style in a &lt;font face="Courier New" color=#808080&gt;TreeView&lt;/font&gt;.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;&amp;lt;mytree:treeview&amp;nbsp;runat="server"&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font face="Courier New" color=#808080&gt;ID="tvwResources"&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;strong&gt;defaultStyle&lt;/strong&gt;="font-family:Verdana,Arial,Sans-serif;color:#000000;font-size:11px;"&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;strong&gt;hoverStyle&lt;/strong&gt;="font-family:Verdana,Arial,Sans-serif;color:#000000;font-size:11px;"&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;strong&gt;selectedStyle&lt;/strong&gt;="font-family:Verdana,Arial,Sans-serif;color:#000000;font-size:11px;&amp;gt;&lt;br&gt;
&amp;lt;/mytree:treeview&amp;gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;Or programmatically&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;mytree.DefaultStyle["font-family"] = "Verdana,Arial,Sans-serif";&lt;br&gt;
mytree.DefaultStyle["color"] = "#000000";&lt;br&gt;
mytree.DefaultStyle["font-size"] = "11px";&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;mytree.HoverStyle["font-family"] = "Verdana,Arial,Sans-serif";&lt;br&gt;
mytree.HoverStyle["color"] = "#000000";&lt;br&gt;
mytree.HoverStyle["font-size"] = "11px";&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;mytree.SelectedStyle["font-family"] = "Verdana,Arial,Sans-serif";&lt;br&gt;
mytree.SelectedStyle["color"] = "#000000";&lt;br&gt;
mytree.SelectedStyle["font-size"] = "11px";&lt;/font&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=e1b1d457-4422-4d0d-8b9e-52eceba916ce" /&gt;</description>
      <comments>http://net.bloggix.com/CommentView,guid,e1b1d457-4422-4d0d-8b9e-52eceba916ce.aspx</comments>
      <category>C#</category>
      <category>Microsoft</category>
    </item>
    <item>
      <trackback:ping>http://net.bloggix.com/Trackback.aspx?guid=ec7deda2-eb7a-4070-bba4-a52516b074ef</trackback:ping>
      <pingback:server>http://net.bloggix.com/pingback.aspx</pingback:server>
      <pingback:target>http://net.bloggix.com/PermaLink,guid,ec7deda2-eb7a-4070-bba4-a52516b074ef.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://net.bloggix.com/CommentView,guid,ec7deda2-eb7a-4070-bba4-a52516b074ef.aspx</wfw:comment>
      <wfw:commentRss>http://net.bloggix.com/SyndicationService.asmx/GetEntryCommentsRss?guid=ec7deda2-eb7a-4070-bba4-a52516b074ef</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <title>How to: Hide a field based on the value in the DataSource</title>
      <guid isPermaLink="false">http://net.bloggix.com/PermaLink,guid,ec7deda2-eb7a-4070-bba4-a52516b074ef.aspx</guid>
      <link>http://net.bloggix.com/2005/07/01/HowToHideAFieldBasedOnTheValueInTheDataSource.aspx</link>
      <pubDate>Fri, 01 Jul 2005 11:55:41 GMT</pubDate>
      <description>&lt;p&gt;
&amp;nbsp;If you use&amp;nbsp;for example a&amp;nbsp;&lt;font face="Courier New" color=#808080&gt;Repeater&lt;/font&gt; and
you do not want to show some field from the &lt;font face="Courier New" color=#808080&gt;DataSource&lt;/font&gt; based
on a expression, you could use the following solution. This example hides the year
when the year in the &lt;font face="Courier New" color=#808080&gt;DataSource&lt;/font&gt; is zero.
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;&amp;lt;asp:Repeater runat="server" id="rptGroup"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;HeaderTemplate&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;table&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/HeaderTemplate&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;ItemTemplate&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;asp:Label id="lbl" runat="server"&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color=#0000ff&gt;Visible='&amp;lt;%#&lt;strong&gt;&lt;em&gt;DisplayYear&lt;/em&gt;&lt;/strong&gt;(DataBinder.Eval(Container.DataItem,
"year"))%&amp;gt;'&lt;/font&gt;&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;%#DataBinder.Eval(Container.DataItem,
"year")%&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/asp:Label&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/ItemTemplate&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;FooterTemplate&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/table&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/FooterTemplate&amp;gt;&lt;br&gt;
&amp;lt;/asp:Repeater&amp;gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
In the code-behind the following method is added:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;public bool &lt;em&gt;&lt;strong&gt;&lt;font color=#0000ff&gt;DisplayYear&lt;/font&gt;&lt;/strong&gt;&lt;/em&gt;(object
item)&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;int year = 0;&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;try&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;year = Convert.ToInt32(item);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;catch(exception)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;return year != 0;&lt;br&gt;
}&lt;/font&gt;
&lt;/p&gt;
&lt;%#DataBinder.Eval(Container.DataItem, "wi_area")%&gt;&gt;
&lt;td&gt;
&lt;%#DataBinder.Eval(Container.DataItem, "wi_year")%&gt;&lt;/td&gt;
&lt;td&gt;
&lt;%#DataBinder.Eval(Container.DataItem, "co_name")%&gt;&lt;/td&gt;
&lt;td&gt;
&lt;%#DataBinder.Eval(Container.DataItem, "wi_amount")%&gt;&lt;/td&gt;
&lt;td align="right"&gt;
&lt;%#DataBinder.Eval(Container.DataItem, "wi_price", "{0:f}")%&gt;&lt;/td&gt;
&gt;
&gt;
&lt;FOOTERTEMPLATE&gt;
&lt;/FOOTERTEMPLATE&gt;
&lt;img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=ec7deda2-eb7a-4070-bba4-a52516b074ef" /&gt;</description>
      <comments>http://net.bloggix.com/CommentView,guid,ec7deda2-eb7a-4070-bba4-a52516b074ef.aspx</comments>
      <category>ASP.NET</category>
      <category>C#</category>
    </item>
    <item>
      <trackback:ping>http://net.bloggix.com/Trackback.aspx?guid=f6a03501-cdd9-48ef-b56f-7a16a4ace0c4</trackback:ping>
      <pingback:server>http://net.bloggix.com/pingback.aspx</pingback:server>
      <pingback:target>http://net.bloggix.com/PermaLink,guid,f6a03501-cdd9-48ef-b56f-7a16a4ace0c4.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://net.bloggix.com/CommentView,guid,f6a03501-cdd9-48ef-b56f-7a16a4ace0c4.aspx</wfw:comment>
      <wfw:commentRss>http://net.bloggix.com/SyndicationService.asmx/GetEntryCommentsRss?guid=f6a03501-cdd9-48ef-b56f-7a16a4ace0c4</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <font color="#000000">One of my collegea likes to have pop quizes about C# programming
snippets. A question he gave us yesterday was the following: If you have two
classes class A and class B implementing the same interface and class A
is derived from class B and you would cast an instance of class A to the interface and
call a method on that interface, which method is called. The one of class A or
class B? It is actually very simple. Lets have a look at the code:</font>
        </p>
        <p>
          <font face="Courier New" color="#808080">public interface I<br />
{<br />
   string someFunc();<br />
}</font>
        </p>
        <p>
          <font face="Courier New" color="#808080">public class B : I<br />
{<br />
   public string someFunc()<br />
   {<br />
      return "someFunc in class B";<br />
   }<br />
}</font>
        </p>
        <p>
          <font face="Courier New" color="#808080">public class A : B, I<br />
{<br />
   public string someFunc()<br />
   {<br />
      return "someFunc in class A";<br />
   }<br />
}</font>
        </p>
        <p>
          <font color="#000000">Then we need some code to initiate this:</font>
        </p>
        <p>
          <font color="#000000">
            <font face="Courier New" color="#808080">A someClassA = new
A();<br />
I someInterface = (someInterface)someClassA;<br />
Response.Write(I.someFunc());<br /></font>
            <br />
When you try to compile it you will get no errors but looking at your code you will
notice that a line is placed under the someFunc() method of class A telling you that
this method is hiding the method with the same name in class B. This answers already
the question. :) The method of class A is called and the string "someFunc in class
A" is returned.</font>
        </p>
        <p>
          <font color="#000000">To get rid of the nasty line and message you only have to change
the line of code from <font face="Courier New" color="#808080">public string someFunc()</font> to <font face="Courier New" color="#808080">public
new string someFunc()</font> in class A. </font>
        </p>
        <img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=f6a03501-cdd9-48ef-b56f-7a16a4ace0c4" />
      </body>
      <title>Calling methods on derived classes implementing the same interface</title>
      <guid isPermaLink="false">http://net.bloggix.com/PermaLink,guid,f6a03501-cdd9-48ef-b56f-7a16a4ace0c4.aspx</guid>
      <link>http://net.bloggix.com/2005/06/23/CallingMethodsOnDerivedClassesImplementingTheSameInterface.aspx</link>
      <pubDate>Thu, 23 Jun 2005 07:55:19 GMT</pubDate>
      <description>&lt;p&gt;
&lt;font color=#000000&gt;One of my collegea likes to have pop quizes about C# programming
snippets.&amp;nbsp;A question he gave us yesterday was the following: If you have two
classes class A and&amp;nbsp;class B&amp;nbsp;implementing the same interface and class A
is derived from class B and you would cast an instance of class A to the interface&amp;nbsp;and
call a&amp;nbsp;method on that interface, which method is called. The one of class A or
class B? It is actually very simple. Lets have a look at the code:&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;public interface I&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;string someFunc();&lt;br&gt;
}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;public class B : I&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;public string someFunc()&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return "someFunc in class&amp;nbsp;B";&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;public class&amp;nbsp;A : B, I&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;public string someFunc()&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return "someFunc in class&amp;nbsp;A";&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;Then we need some code to initiate this:&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New" color=#808080&gt;A someClassA = new A();&lt;br&gt;
I someInterface = (someInterface)someClassA;&lt;br&gt;
Response.Write(I.someFunc());&lt;br&gt;
&lt;/font&gt;
&lt;br&gt;
When you try to compile it you will get no errors but looking at your code you will
notice that a line is placed under the someFunc() method of class A telling you that
this method is hiding the method with the same name in class B. This answers already
the question. :) The method of class A is called and the string "someFunc in class
A" is returned.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;To get rid of the nasty line and message you only have to change
the line of code from &lt;font face="Courier New" color=#808080&gt;public string someFunc()&lt;/font&gt; to &lt;font face="Courier New" color=#808080&gt;public
new string someFunc()&lt;/font&gt; in class A. &lt;/font&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=f6a03501-cdd9-48ef-b56f-7a16a4ace0c4" /&gt;</description>
      <comments>http://net.bloggix.com/CommentView,guid,f6a03501-cdd9-48ef-b56f-7a16a4ace0c4.aspx</comments>
      <category>C#</category>
    </item>
    <item>
      <trackback:ping>http://net.bloggix.com/Trackback.aspx?guid=d5839535-f38d-42a1-a662-85172e4f0232</trackback:ping>
      <pingback:server>http://net.bloggix.com/pingback.aspx</pingback:server>
      <pingback:target>http://net.bloggix.com/PermaLink,guid,d5839535-f38d-42a1-a662-85172e4f0232.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://net.bloggix.com/CommentView,guid,d5839535-f38d-42a1-a662-85172e4f0232.aspx</wfw:comment>
      <wfw:commentRss>http://net.bloggix.com/SyndicationService.asmx/GetEntryCommentsRss?guid=d5839535-f38d-42a1-a662-85172e4f0232</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
At the blog <a href="http://weblogs.asp.net/mnissen/">#region /* mads's thoughts */</a> an
important article is found called "COM objects need tight leash". It gives an example
of increasing memory usage when working with the SharePoint object model and th Office
interop components. 
</p>
        <p>
In that case it seems that the Garbage Collector was cleaning up the managed
references which were wrappers around COM objects and these COM objects were not cleaned
up.
</p>
        <p>
I have had a similair problem in the past writing wrapper classes in C# around C++
unmanaged code. The unmanaged code was not cleaned up by the garbage collector ofcourse
and you had to do that yourself.
</p>
        <a href="http://weblogs.asp.net/mnissen/archive/2005/06/22/414247.aspx">http://weblogs.asp.net/mnissen/archive/2005/06/22/414247.aspx</a>
        <img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=d5839535-f38d-42a1-a662-85172e4f0232" />
      </body>
      <title>Always handle and clean up unmanaged references and objects</title>
      <guid isPermaLink="false">http://net.bloggix.com/PermaLink,guid,d5839535-f38d-42a1-a662-85172e4f0232.aspx</guid>
      <link>http://net.bloggix.com/2005/06/22/AlwaysHandleAndCleanUpUnmanagedReferencesAndObjects.aspx</link>
      <pubDate>Wed, 22 Jun 2005 09:50:05 GMT</pubDate>
      <description>&lt;p&gt;
At the blog &lt;a href="http://weblogs.asp.net/mnissen/"&gt;#region /* mads's thoughts */&lt;/a&gt; an
important article is found called "COM objects need tight leash". It gives an example
of increasing memory usage when working with the SharePoint object model and th Office
interop components. 
&lt;/p&gt;
&lt;p&gt;
In that case it&amp;nbsp;seems that the Garbage Collector was cleaning up the managed
references which were wrappers around COM objects and these COM objects were not cleaned
up.
&lt;/p&gt;
&lt;p&gt;
I have had a similair problem in the past writing wrapper classes in C# around C++
unmanaged code. The unmanaged code was not cleaned up by the garbage collector ofcourse
and you had to do that yourself.
&lt;/p&gt;
&lt;a href="http://weblogs.asp.net/mnissen/archive/2005/06/22/414247.aspx"&gt;http://weblogs.asp.net/mnissen/archive/2005/06/22/414247.aspx&lt;/a&gt; &lt;img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=d5839535-f38d-42a1-a662-85172e4f0232" /&gt;</description>
      <comments>http://net.bloggix.com/CommentView,guid,d5839535-f38d-42a1-a662-85172e4f0232.aspx</comments>
      <category>.NET</category>
      <category>C#</category>
      <category>SharePoint</category>
    </item>
    <item>
      <trackback:ping>http://net.bloggix.com/Trackback.aspx?guid=2fdad67d-6c67-47c3-b79e-a4ee27362936</trackback:ping>
      <pingback:server>http://net.bloggix.com/pingback.aspx</pingback:server>
      <pingback:target>http://net.bloggix.com/PermaLink,guid,2fdad67d-6c67-47c3-b79e-a4ee27362936.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://net.bloggix.com/CommentView,guid,2fdad67d-6c67-47c3-b79e-a4ee27362936.aspx</wfw:comment>
      <wfw:commentRss>http://net.bloggix.com/SyndicationService.asmx/GetEntryCommentsRss?guid=2fdad67d-6c67-47c3-b79e-a4ee27362936</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <font color="#000000">In one of the portals we removed the "Site settings" link from
the page to prevent users clicking on it. For some additional users which have
administrator rights we created a WebPart containing links to the most needed
functionality. This custom WebPart contains a direct link to the settings of the current
page, a direct link to the settings of users of the current page and a link to delete
the current page and its children. </font>
        </p>
        <p>
          <img src="http://blogs.tamtam.nl/alexander/content/binary/settingswebpart.jpg" border="0" />
        </p>
        <p>
          <font color="#000000">First define a linkbutton in your WebPart derived class. This
button is used for deleting the site and its children.</font>
        </p>
        <font size="2">
          <font size="2">
            <p>
            </p>
          </font>
          <font color="#808080">
            <font face="Courier New">
              <font size="2">private</font>
              <font size="2"> LinkButton
btnDeleteSite = </font>
              <font size="2">null</font>
              <font size="2">;</font>
            </font>
          </font>
          <p>
            <font size="2">
              <font color="#000000">In the OnLoad method create the button and set
the visibility of the WebPart.</font>
            </font>
          </p>
          <p>
          </p>
        </font>
        <font color="#808080">
          <font face="Courier New">
            <font size="2">protected</font>
            <font size="2">
            </font>
            <font size="2">override</font>
            <font size="2">
            </font>
            <font size="2">void</font>
          </font>
        </font>
        <font face="Courier New" color="#808080" size="2"> OnLoad(EventArgs
e)<br /></font>
        <font color="#808080">
          <font face="Courier New">
            <font size="2">{<br />
   </font>
            <font size="2">base</font>
            <font size="2">.OnLoad(e);</font>
          </font>
        </font>
        <p>
          <font color="#808080">
            <font face="Courier New">
              <font size="2">   btnDeleteSite
= </font>
              <font size="2">new</font>
            </font>
          </font>
          <font color="#808080">
            <font face="Courier New">
              <font size="2"> LinkButton();<br />
   btnDeleteSite.ID = </font>
              <font size="2">"btnDeleteSite"</font>
            </font>
          </font>
          <font color="#808080">
            <font face="Courier New">
              <font size="2">;<br />
   btnDeleteSite.Text = </font>
              <font size="2">"Delete this site"</font>
            </font>
          </font>
          <font color="#808080">
            <font face="Courier New">
              <font size="2">;<br />
   btnDeleteSite.Click += </font>
              <font size="2">new</font>
            </font>
          </font>
          <font face="Courier New" color="#808080" size="2"> EventHandler(btnDeleteSite_Click);<br />
   Controls.Add(btnDeleteSite);</font>
        </p>
        <font size="2">
          <font size="2">
            <p>
              <font face="Courier New" color="#808080">   Visible = IsVisible;</font>
            </p>
          </font>
          <br />
          <font face="Courier New" color="#808080">}</font>
          <p>
            <font color="#000000">This property returns true if the current user has rights to
manage the web. If not the WebPart is not displayed on the page.</font>
          </p>
          <font size="2">
            <p>
            </p>
          </font>
          <font color="#808080">
            <font face="Courier New">
              <font size="2">protected</font>
              <font size="2">
              </font>
              <font size="2">virtual</font>
              <font size="2">
              </font>
              <font size="2">bool</font>
            </font>
          </font>
          <font face="Courier New" color="#808080" size="2"> IsVisible<br />
{<br />
   </font>
          <font face="Courier New" color="#808080" size="2">get<br />
   </font>
          <font size="2">
            <font face="Courier New" color="#808080">{<br />
      SPWeb web = SPControl.GetContextWeb(Context);</font>
            <p>
            </p>
          </font>
          <font color="#808080">
            <font face="Courier New">
              <font size="2">      if</font>
              <font size="2"> (web
== </font>
              <font size="2">null</font>
            </font>
          </font>
          <font color="#808080">
            <font face="Courier New">
              <font size="2">)<br />
      {<br />
      </font>
              <font size="2">   return</font>
              <font size="2">
              </font>
              <font size="2">false</font>
            </font>
          </font>
          <font size="2">
            <font face="Courier New" color="#808080">;<br />
      }</font>
            <p>
              <font face="Courier New" color="#808080">      SPUser
user = web.CurrentUser;</font>
            </p>
            <p>
            </p>
          </font>
          <font face="Courier New" color="#808080" size="2">      bool</font>
          <font size="2">
            <font face="Courier New" color="#808080"> hasRight
= web.Permissions.DoesUserHavePermissions(SPRights.ManageWeb);</font>
            <p>
            </p>
          </font>
          <font face="Courier New" color="#808080" size="2">      return</font>
          <font face="Courier New" color="#808080" size="2"> hasRight;<br />
   }<br />
}</font>
          <p>
            <font size="2">
              <font color="#000000">Override the RenderWebPart method and create
the three links which give access to the site settings, user settings and deletion
of the site and its children.</font>
            </font>
          </p>
        </font>
        <p>
          <font face="Courier New" color="#808080">protected</font>
          <font color="#808080">
            <font face="Courier New">
              <font size="2">
              </font>
              <font size="2">override</font>
              <font size="2">
              </font>
              <font size="2">void</font>
            </font>
          </font>
          <font face="Courier New" color="#808080" size="2"> RenderWebPart(HtmlTextWriter
output)<br />
{<br />
   output.WriteLine(</font>
          <font color="#808080">
            <font face="Courier New">
              <font size="2">"&lt;table
width=100% cellpadding=\"0\" " + <br />
                    </font>
            </font>
          </font>
          <font color="#808080">
            <font face="Courier New">
              <font size="2">"cellspacing=\"0\"
border=\"0\" " +<br />
                    "</font>
              <font size="2">style=\"margin-top:
3px;margin-left: " + <br />
                    </font>
            </font>
          </font>
          <font color="#808080">
            <font face="Courier New">
              <font size="2">"3px;margin-right:
3px;\"&gt;"</font>
            </font>
          </font>
          <font color="#808080">
            <font face="Courier New">
              <font size="2">);</font>
            </font>
          </font>
        </p>
        <p>
          <font color="#808080">
            <font face="Courier New">
              <font size="2">   output.WriteLine(</font>
              <font size="2">"&lt;tr&gt;&lt;td&gt;"</font>
            </font>
          </font>
          <font color="#808080">
            <font face="Courier New">
              <font size="2">);<br />
   output.WriteLine(</font>
              <font size="2">"Make your choice:"</font>
            </font>
          </font>
          <font color="#808080">
            <font face="Courier New">
              <font size="2">);<br />
   output.WriteLine(</font>
              <font size="2">"&lt;br&gt;&lt;br&gt;"</font>
            </font>
          </font>
          <font color="#808080">
            <font face="Courier New">
              <font size="2">);<br />
   output.WriteLine(</font>
              <font size="2">"&lt;/td&gt;&lt;/tr&gt;"</font>
              <font size="2">);</font>
            </font>
          </font>
        </p>
        <p>
          <font face="Courier New" color="#808080" size="2">   output.WriteLine(</font>
          <font face="Courier New" color="#808080" size="2">"&lt;tr&gt;&lt;td
class=\"ms-addnew\" style=\"padding-bottom: " + <br />
                    </font>
          <font face="Courier New" color="#808080" size="2">"3px\"
colspan=\"2\"&gt; " + <br />
                    "&lt;img
src=\"/_layouts/images/rect.gif\" alt=\"\"&gt;&amp;nbsp;"</font>
          <font color="#808080">
            <font face="Courier New">
              <font size="2">);<br /></font>
            </font>
          </font>
          <font color="#808080">
            <font face="Courier New">
              <font size="2">
                <br />
   output.WriteLine(</font>
              <font size="2">"&lt;a href='_layouts/"</font>
            </font>
          </font>
          <font color="#808080">
            <font face="Courier New">
              <font size="2"> + <br />
                    System.Threading.Thread.CurrentThread.CurrentUICulture.LCID
+  <br />
                    </font>
              <font size="2">"/settings.aspx'&gt;Site
settings&lt;/a&gt;"</font>
              <font size="2">);</font>
            </font>
          </font>
        </p>
        <p>
          <font color="#808080">
            <font face="Courier New">
              <font size="2">   output.WriteLine(</font>
              <font size="2">"&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;tr&gt;"</font>
              <font size="2">);</font>
            </font>
          </font>
        </p>
        <p>
          <font face="Courier New" color="#808080" size="2">   output.WriteLine(</font>
          <font face="Courier New" color="#808080" size="2">"&lt;tr&gt;&lt;td
class=\"ms-addnew\" style=\"padding-bottom: 3px\" " + <br />
                    "colspan=\"2\"&gt;
" +<br />
                   
"&lt;img src=\"/_layouts/images/rect.gif\" alt=\"\"&gt;&amp;nbsp;"</font>
          <font color="#808080">
            <font face="Courier New">
              <font size="2">);<br /><br />
   output.WriteLine(</font>
              <font size="2">"&lt;a href='_layouts/"</font>
            </font>
          </font>
          <font color="#808080">
            <font face="Courier New">
              <font size="2"> + <br />
                    </font>
            </font>
          </font>
          <font color="#808080">
            <font face="Courier New">
              <font size="2">System.Threading.Thread.CurrentThread.CurrentUICulture.LCID
+ <br />
                    </font>
              <font size="2">"/user.aspx'&gt;User
settings&lt;/a&gt;"</font>
              <font size="2">);</font>
            </font>
          </font>
        </p>
        <p>
          <font color="#808080">
            <font face="Courier New">
              <font size="2">   output.WriteLine(</font>
              <font size="2">"&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;"</font>
              <font size="2">);</font>
            </font>
          </font>
        </p>
        <p>
          <font face="Courier New" color="#808080" size="2">   output.WriteLine(</font>
          <font face="Courier New" color="#808080" size="2">"&lt;tr&gt;&lt;td
class=\"ms-addnew\" style=\"padding-bottom: " + <br />
                    "3px\"
colspan=\"2\"&gt; " + <br />
                    "&lt;img
src=\"/_layouts/images/rect.gif\" alt=\"\"&gt;&amp;nbsp;"</font>
          <font face="Courier New" color="#808080" size="2">);<br /></font>
          <font face="Courier New" color="#808080" size="2">
            <br />
          </font>
          <font size="2">
            <font face="Courier New" color="#808080">   btnDeleteSite.RenderControl(output);</font>
          </font>
        </p>
        <p>
          <font face="Courier New" color="#808080">   output.WriteLine(</font>
          <font face="Courier New" color="#808080" size="2">"&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;tr&gt;"</font>
          <font color="#808080">
            <font face="Courier New">
              <font size="2">);<br />
   output.WriteLine(</font>
              <font size="2">"&lt;/table&gt;"</font>
            </font>
          </font>
          <font color="#808080">
            <font face="Courier New">
              <font size="2">);<br /></font>
              <font size="2">}</font>
            </font>
          </font>
        </p>
        <p>
          <font color="#000000">This is the member called when the delete button is pressed.
It deletes the site and its children by calling the member DeleteSite and then redirects
to the page of its parent.</font>
        </p>
        <font size="2">
          <font size="2">
            <p>
            </p>
          </font>
          <font color="#808080">
            <font face="Courier New">
              <font size="2">priva</font>
              <font size="2">te</font>
              <font size="2">
              </font>
              <font size="2">void</font>
              <font size="2"> btnDeleteSite_Click(</font>
              <font size="2">object</font>
            </font>
          </font>
          <font face="Courier New" color="#808080" size="2"> sender,
EventArgs e)<br />
{<br />
   SPWeb web = SPControl.GetContextWeb(Context);<br />
   SPWeb parentWeb = web.ParentWeb;</font>
          <p>
            <font face="Courier New" color="#808080" size="2">   DeleteSite(web);</font>
          </p>
          <p>
            <font face="Courier New" color="#808080" size="2">   Page.Response.Redirect(parentWeb.Url);<br />
}</font>
          </p>
          <p>
            <font color="#000000">The last method is used for deleting the site and its children.
We loop through the <font face="Courier New" color="#808080">Webs</font> collection
of the current web and delete it from its parents collection.</font>
          </p>
          <font size="2">
            <font size="2">
              <p>
              </p>
            </font>
            <font color="#808080">
              <font face="Courier New">
                <font size="2">private</font>
                <font size="2">
                </font>
                <font size="2">void</font>
              </font>
            </font>
            <font color="#808080">
              <font face="Courier New">
                <font size="2"> DeleteSite(SPWeb
web)<br />
{<br />
   </font>
                <font size="2">if</font>
                <font size="2"> (web == </font>
                <font size="2">null</font>
                <font size="2"> ||
web.Webs == </font>
                <font size="2">null</font>
              </font>
            </font>
            <font color="#808080">
              <font face="Courier New">
                <font size="2">)<br />
   {<br />
      </font>
                <font size="2">return</font>
              </font>
            </font>
            <font size="2">
              <font face="Courier New" color="#808080">;<br />
   }</font>
              <p>
              </p>
            </font>
            <font face="Courier New" color="#808080" size="2">   string</font>
            <font size="2">
              <font face="Courier New" color="#808080">[]
t = web.Webs.Names;</font>
              <p>
              </p>
            </font>
            <font color="#808080">
              <font face="Courier New">
                <font size="2">   foreach</font>
                <font size="2">(SPWeb
subWeb </font>
                <font size="2">in</font>
              </font>
            </font>
            <font size="2">
              <font face="Courier New" color="#808080"> web.Webs)<br />
   {<br />
      DeleteSite(subWeb);<br />
   }</font>
              <p>
              </p>
            </font>
            <font face="Courier New" color="#808080" size="2">   try<br />
   </font>
            <font face="Courier New" color="#808080" size="2">{<br />
      </font>
            <font face="Courier New" color="#808080" size="2">//
delete from database<br />
      </font>
            <font size="2">
              <font face="Courier New" color="#808080">SPWeb
parentWeb = web.ParentWeb;</font>
              <p>
              </p>
            </font>
            <font color="#808080">
              <font face="Courier New">
                <font size="2">      //
delete from its parents list<br />
      </font>
                <font size="2">if</font>
                <font size="2"> (parentWeb
!= </font>
                <font size="2">null</font>
              </font>
            </font>
            <font size="2">
              <font face="Courier New" color="#808080">)<br />
      {<br />
         parentWeb.Webs.Delete(web.Name);</font>
              <p>
                <font face="Courier New" color="#808080">         parentWeb.Update();<br />
      }<br />
   }<br />
   </font>
              </p>
            </font>
            <font face="Courier New" color="#808080" size="2">catch</font>
            <font face="Courier New" color="#808080" size="2">(Exception
e)<br />
   </font>
            <font color="#808080">
              <font face="Courier New">
                <font size="2">{<br />
      </font>
                <font size="2">string</font>
              </font>
            </font>
            <font size="2">
              <font face="Courier New" color="#808080"> s
= e.Message;<br />
   }<br />
}</font>
            </font>
          </font>
        </font>
        <img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=2fdad67d-6c67-47c3-b79e-a4ee27362936" />
      </body>
      <title>Custom Site Settings WebPart</title>
      <guid isPermaLink="false">http://net.bloggix.com/PermaLink,guid,2fdad67d-6c67-47c3-b79e-a4ee27362936.aspx</guid>
      <link>http://net.bloggix.com/2005/06/06/CustomSiteSettingsWebPart.aspx</link>
      <pubDate>Mon, 06 Jun 2005 08:05:29 GMT</pubDate>
      <description>&lt;p&gt;
&lt;font color=#000000&gt;In one of the portals we removed the "Site settings" link from
the page to prevent users clicking on it. For some&amp;nbsp;additional users which have
administrator rights we created&amp;nbsp;a WebPart containing links to the most needed
functionality. This custom WebPart contains a direct link to the settings of the current
page, a direct link to the settings of users of the current page and a link to delete
the current page and its children. &lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://blogs.tamtam.nl/alexander/content/binary/settingswebpart.jpg" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;First define a linkbutton in your WebPart derived class. This
button is used for deleting the site and its children.&lt;/font&gt;
&lt;/p&gt;
&lt;font size=2&gt;&lt;font size=2&gt; 
&lt;p&gt;
&lt;/font&gt;&lt;font color=#808080&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;private&lt;/font&gt;&lt;font size=2&gt; LinkButton
btnDeleteSite = &lt;/font&gt;&lt;font size=2&gt;null&lt;/font&gt;&lt;font size=2&gt;;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&gt;
&lt;p&gt;
&lt;font size=2&gt;&lt;font color=#000000&gt;In the OnLoad method create the button and set the
visibility of the WebPart.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/font&gt;&lt;font color=#808080&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;protected&lt;/font&gt;&lt;font size=2&gt; &lt;/font&gt;&lt;font size=2&gt;override&lt;/font&gt;&lt;font size=2&gt; &lt;/font&gt;&lt;font size=2&gt;void&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New" color=#808080 size=2&gt; OnLoad(EventArgs
e)&lt;br&gt;
&lt;/font&gt;&lt;font color=#808080&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font size=2&gt;base&lt;/font&gt;&lt;font size=2&gt;.OnLoad(e);&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&gt;
&lt;p&gt;
&lt;font color=#808080&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;btnDeleteSite
= &lt;/font&gt;&lt;font size=2&gt;new&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font color=#808080&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt; LinkButton();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;btnDeleteSite.ID = &lt;/font&gt;&lt;font size=2&gt;"btnDeleteSite"&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font color=#808080&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;btnDeleteSite.Text = &lt;/font&gt;&lt;font size=2&gt;"Delete this site"&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font color=#808080&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;btnDeleteSite.Click += &lt;/font&gt;&lt;font size=2&gt;new&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New" color=#808080 size=2&gt; EventHandler(btnDeleteSite_Click);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;Controls.Add(btnDeleteSite);&lt;/font&gt;
&lt;/p&gt;
&lt;font size=2&gt;&lt;font size=2&gt; 
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Visible = IsVisible;&lt;/font&gt;
&lt;/font&gt;
&lt;br&gt;
&lt;font face="Courier New" color=#808080&gt;}&lt;/font&gt;&gt;
&lt;p&gt;
&lt;font color=#000000&gt;This property returns true if the current user has rights to manage
the web. If not the WebPart is not displayed on the page.&lt;/font&gt;
&lt;/p&gt;
&lt;font size=2&gt; 
&lt;p&gt;
&lt;/font&gt;&lt;font color=#808080&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;protected&lt;/font&gt;&lt;font size=2&gt; &lt;/font&gt;&lt;font size=2&gt;virtual&lt;/font&gt;&lt;font size=2&gt; &lt;/font&gt;&lt;font size=2&gt;bool&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New" color=#808080 size=2&gt; IsVisible&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font face="Courier New" color=#808080 size=2&gt;get&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New" color=#808080&gt;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;SPWeb web = SPControl.GetContextWeb(Context);&lt;/font&gt;&gt;
&lt;p&gt;
&lt;/font&gt;&lt;font color=#808080&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if&lt;/font&gt;&lt;font size=2&gt; (web
== &lt;/font&gt;&lt;font size=2&gt;null&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font color=#808080&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&lt;/font&gt;&lt;font size=2&gt; &lt;/font&gt;&lt;font size=2&gt;false&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New" color=#808080&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/font&gt;&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;SPUser
user = web.CurrentUser;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/font&gt;&lt;font face="Courier New" color=#808080 size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;bool&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New" color=#808080&gt; hasRight
= web.Permissions.DoesUserHavePermissions(SPRights.ManageWeb);&lt;/font&gt;&gt;
&lt;p&gt;
&lt;/font&gt;&lt;font face="Courier New" color=#808080 size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&lt;/font&gt;&lt;font face="Courier New" color=#808080 size=2&gt; hasRight;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
}&lt;/font&gt;&gt;
&lt;p&gt;
&lt;font size=2&gt;&lt;font color=#000000&gt;Override the RenderWebPart method and create the
three links which give access to the site settings, user settings and deletion of
the site and its children.&lt;/font&gt;
&lt;/p&gt;
&lt;/font&gt;&gt; 
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;protected&lt;/font&gt;&gt;&lt;font color=#808080&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt; &lt;/font&gt;&lt;font size=2&gt;override&lt;/font&gt;&lt;font size=2&gt; &lt;/font&gt;&lt;font size=2&gt;void&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New" color=#808080 size=2&gt; RenderWebPart(HtmlTextWriter
output)&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;output.WriteLine(&lt;/font&gt;&lt;font color=#808080&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;"&amp;lt;table
width=100% cellpadding=\"0\" " +&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font color=#808080&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;"cellspacing=\"0\"
border=\"0\"&amp;nbsp;" +&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;"&lt;/font&gt;&lt;font size=2&gt;style=\"margin-top:
3px;margin-left: " +&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font color=#808080&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;"3px;margin-right:
3px;\"&amp;gt;"&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font color=#808080&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;);&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#808080&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;output.WriteLine(&lt;/font&gt;&lt;font size=2&gt;"&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;"&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font color=#808080&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;output.WriteLine(&lt;/font&gt;&lt;font size=2&gt;"Make your choice:"&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font color=#808080&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;output.WriteLine(&lt;/font&gt;&lt;font size=2&gt;"&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;"&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font color=#808080&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;output.WriteLine(&lt;/font&gt;&lt;font size=2&gt;"&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;"&lt;/font&gt;&lt;font size=2&gt;);&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080 size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;output.WriteLine(&lt;/font&gt;&lt;font face="Courier New" color=#808080 size=2&gt;"&amp;lt;tr&amp;gt;&amp;lt;td
class=\"ms-addnew\" style=\"padding-bottom: " +&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font face="Courier New" color=#808080 size=2&gt;"3px\"
colspan=\"2\"&amp;gt;&amp;nbsp;" +&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;"&amp;lt;img
src=\"/_layouts/images/rect.gif\" alt=\"\"&amp;gt;&amp;amp;nbsp;"&lt;/font&gt;&lt;font color=#808080&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;);&lt;br&gt;
&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font color=#808080&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;output.WriteLine(&lt;/font&gt;&lt;font size=2&gt;"&amp;lt;a href='_layouts/"&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font color=#808080&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt; +&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;System.Threading.Thread.CurrentThread.CurrentUICulture.LCID
+&amp;nbsp;&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font size=2&gt;"/settings.aspx'&amp;gt;Site
settings&amp;lt;/a&amp;gt;"&lt;/font&gt;&lt;font size=2&gt;);&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#808080&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;output.WriteLine(&lt;/font&gt;&lt;font size=2&gt;"&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;tr&amp;gt;"&lt;/font&gt;&lt;font size=2&gt;);&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080 size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;output.WriteLine(&lt;/font&gt;&lt;font face="Courier New" color=#808080 size=2&gt;"&amp;lt;tr&amp;gt;&amp;lt;td
class=\"ms-addnew\" style=\"padding-bottom: 3px\" " +&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;"colspan=\"2\"&amp;gt;
" +&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
"&amp;lt;img src=\"/_layouts/images/rect.gif\" alt=\"\"&amp;gt;&amp;amp;nbsp;"&lt;/font&gt;&lt;font color=#808080&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;);&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;output.WriteLine(&lt;/font&gt;&lt;font size=2&gt;"&amp;lt;a href='_layouts/"&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font color=#808080&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt; +&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font color=#808080&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;System.Threading.Thread.CurrentThread.CurrentUICulture.LCID
+&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font size=2&gt;"/user.aspx'&amp;gt;User
settings&amp;lt;/a&amp;gt;"&lt;/font&gt;&lt;font size=2&gt;);&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#808080&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;output.WriteLine(&lt;/font&gt;&lt;font size=2&gt;"&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;"&lt;/font&gt;&lt;font size=2&gt;);&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080 size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;output.WriteLine(&lt;/font&gt;&lt;font face="Courier New" color=#808080 size=2&gt;"&amp;lt;tr&amp;gt;&amp;lt;td
class=\"ms-addnew\" style=\"padding-bottom: " +&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;"3px\"
colspan=\"2\"&amp;gt; " +&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;"&amp;lt;img
src=\"/_layouts/images/rect.gif\" alt=\"\"&amp;gt;&amp;amp;nbsp;"&lt;/font&gt;&lt;font face="Courier New" color=#808080 size=2&gt;);&lt;br&gt;
&lt;/font&gt;&lt;font face="Courier New" color=#808080 size=2&gt;
&lt;br&gt;
&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New" color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;btnDeleteSite.RenderControl(output);&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;output.WriteLine(&lt;/font&gt;&gt;&lt;font face="Courier New" color=#808080 size=2&gt;"&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;tr&amp;gt;"&lt;/font&gt;&lt;font color=#808080&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;output.WriteLine(&lt;/font&gt;&lt;font size=2&gt;"&amp;lt;/table&amp;gt;"&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font color=#808080&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;);&lt;br&gt;
&lt;/font&gt;&lt;font size=2&gt;}&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;This is the member called when the delete button is pressed. It
deletes the site and its children by calling the member DeleteSite and then redirects
to the page of its parent.&lt;/font&gt;
&lt;/p&gt;
&lt;font size=2&gt;&lt;font size=2&gt; 
&lt;p&gt;
&lt;/font&gt;&lt;font color=#808080&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;priva&lt;/font&gt;&lt;font size=2&gt;te&lt;/font&gt;&lt;font size=2&gt; &lt;/font&gt;&lt;font size=2&gt;void&lt;/font&gt;&lt;font size=2&gt; btnDeleteSite_Click(&lt;/font&gt;&lt;font size=2&gt;object&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New" color=#808080 size=2&gt; sender,
EventArgs e)&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;SPWeb web = SPControl.GetContextWeb(Context);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;SPWeb parentWeb = web.ParentWeb;&lt;/font&gt;&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080 size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;DeleteSite(web);&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080 size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Page.Response.Redirect(parentWeb.Url);&lt;br&gt;
}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;The last method is used for deleting the site and its children.
We loop through the &lt;font face="Courier New" color=#808080&gt;Webs&lt;/font&gt; collection
of the current web and delete it from its parents collection.&lt;/font&gt;
&lt;/p&gt;
&lt;font size=2&gt;&lt;font size=2&gt; 
&lt;p&gt;
&lt;/font&gt;&lt;font color=#808080&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;private&lt;/font&gt;&lt;font size=2&gt; &lt;/font&gt;&lt;font size=2&gt;void&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font color=#808080&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt; DeleteSite(SPWeb
web)&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font size=2&gt;if&lt;/font&gt;&lt;font size=2&gt; (web == &lt;/font&gt;&lt;font size=2&gt;null&lt;/font&gt;&lt;font size=2&gt; ||
web.Webs == &lt;/font&gt;&lt;font size=2&gt;null&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font color=#808080&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font size=2&gt;return&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New" color=#808080&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/font&gt;&gt;
&lt;p&gt;
&lt;/font&gt;&lt;font face="Courier New" color=#808080 size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;string&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New" color=#808080&gt;[]
t = web.Webs.Names;&lt;/font&gt;&gt;
&lt;p&gt;
&lt;/font&gt;&lt;font color=#808080&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;foreach&lt;/font&gt;&lt;font size=2&gt;(SPWeb
subWeb &lt;/font&gt;&lt;font size=2&gt;in&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New" color=#808080&gt; web.Webs)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;DeleteSite(subWeb);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/font&gt;&gt;
&lt;p&gt;
&lt;/font&gt;&lt;font face="Courier New" color=#808080 size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;try&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font face="Courier New" color=#808080 size=2&gt;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font face="Courier New" color=#808080 size=2&gt;//
delete from database&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New" color=#808080&gt;SPWeb
parentWeb = web.ParentWeb;&lt;/font&gt;&gt;
&lt;p&gt;
&lt;/font&gt;&lt;font color=#808080&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//
delete from its parents list&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font size=2&gt;if&lt;/font&gt;&lt;font size=2&gt; (parentWeb
!= &lt;/font&gt;&lt;font size=2&gt;null&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New" color=#808080&gt;)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;parentWeb.Webs.Delete(web.Name);&lt;/font&gt;&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;parentWeb.Update();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;
&lt;/font&gt;&lt;font face="Courier New" color=#808080 size=2&gt;catch&lt;/font&gt;&lt;font face="Courier New" color=#808080 size=2&gt;(Exception
e)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font color=#808080&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font size=2&gt;string&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New" color=#808080&gt; s
= e.Message;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
}&lt;/font&gt;&gt;
&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=2fdad67d-6c67-47c3-b79e-a4ee27362936" /&gt;</description>
      <comments>http://net.bloggix.com/CommentView,guid,2fdad67d-6c67-47c3-b79e-a4ee27362936.aspx</comments>
      <category>C#</category>
      <category>SharePoint</category>
    </item>
    <item>
      <trackback:ping>http://net.bloggix.com/Trackback.aspx?guid=2a1bbac3-4bf9-4e55-bbe2-2b9c61058071</trackback:ping>
      <pingback:server>http://net.bloggix.com/pingback.aspx</pingback:server>
      <pingback:target>http://net.bloggix.com/PermaLink,guid,2a1bbac3-4bf9-4e55-bbe2-2b9c61058071.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://net.bloggix.com/CommentView,guid,2a1bbac3-4bf9-4e55-bbe2-2b9c61058071.aspx</wfw:comment>
      <wfw:commentRss>http://net.bloggix.com/SyndicationService.asmx/GetEntryCommentsRss?guid=2a1bbac3-4bf9-4e55-bbe2-2b9c61058071</wfw:commentRss>
      <slash:comments>3</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <font size="2">
          <p>
For one of our customers we needed a specific overview of their KPI's (Key Perfomance
Indicators) per defined SLA (Service Level Agreement). The standard Web Parts deliverd
by MOBSA (Microsoft Office Business Scorecard Accelerator) were not providing
enough possibilities. We decided to build our own custom Web Part using the MOBSA
API. It is a very powerfull API and in this example we use it for showing multiple
KPI statuses per defined SLA.
</p>
        </font>
        <p>
          <font color="#0000ff" size="2">
            <img src="http://blogs.tamtam.nl/alexander/content/binary/sla_overview.jpg" border="0" />
          </font>
        </p>
        <p>
          <font color="#000000">There are some methods used in the example for which no code
is deliverd. I will give a short explanation per method and their return values. The
property SLACode is actually a Site property keeping the name of the SLA of the customer.
Each customer has its own site in the SharePoint Portal.</font>
        </p>
        <p>
          <font color="#000000">The method GetSliceDefCollection returns a <font size="2"><font face="Courier New" color="#808080">SliceDefCollection</font> collection
class containing different slices of values used by the <font face="Courier New" color="#808080">QueryAllKPIData</font> to
retrieve the correct slice from the cubicle. The slices represent Shared Dimensions
in SQL Analysis Server. An example could be something like this:</font></font>
        </p>
        <font color="#000000">
          <font size="2">
            <font size="2">
              <p>
              </p>
            </font>
            <font face="Courier New">
              <font color="#808080">
                <font size="2">private</font>
                <font size="2"> SliceDefCollection
GetSliceDefCollection(string SLACode</font>
              </font>
            </font>
            <font face="Courier New">
              <font color="#808080">
                <font size="2">)<br />
{<br />
   </font>
                <font size="2">SliceDefCollection sliceDefs = </font>
                <font size="2">new</font>
              </font>
            </font>
            <font size="2">
              <font face="Courier New" color="#808080"> SliceDefCollection();</font>
              <p>
                <font face="Courier New" color="#808080">   SliceDef def = </font>
              </p>
            </font>
            <font face="Courier New" color="#808080" size="2">new</font>
            <font face="Courier New">
              <font color="#808080">
                <font size="2"> SliceDef();<br />
   def.Slice = </font>
                <font size="2">"[Time].[2005</font>
                <font size="2">].[januari</font>
                <font size="2">]"</font>
              </font>
            </font>
            <font size="2">
              <font face="Courier New" color="#808080">;<br />
   sliceDefs.Add(def);</font>
              <p>
                <font face="Courier New" color="#808080">   def = </font>
              </p>
            </font>
            <font face="Courier New" color="#808080" size="2">new</font>
            <font face="Courier New">
              <font color="#808080">
                <font size="2"> SliceDef();<br />
   def.Slice = </font>
                <font size="2">"[SLACode].[" + SLACode + </font>
                <font size="2">]"</font>
              </font>
            </font>
            <font size="2">
              <font face="Courier New" color="#808080">;<br />
   sliceDefs.Add(def);</font>
              <p>
              </p>
            </font>
            <font face="Courier New" color="#808080" size="2">   return</font>
            <font size="2">
              <font face="Courier New" color="#808080"> sliceDefs;<br />
}</font>
            </font>
            <p>
              <font size="2">
                <font color="#000000">Finally we also use a method </font>
                <font face="Courier New" color="#808080">
                  <font color="#808080">GetShortManagementName</font>
                  <font face="Verdana" color="#000000"> to
retrieve the management part names.</font>
                </font>
              </font>
            </p>
          </font>
        </font>
        <p>
          <font color="#000000">I have posted the method <font face="Courier New" color="#808080">RenderWebPart</font> and
have put some comment between the code to explain what i'm doing. You need to reference
the <font face="Courier New" color="#808080">MSScoreCardWebParts</font> assembly and
at the top of the code the namespaces <font size="2"><font face="Courier New" color="#808080">Microsoft.BusinessIntelligence.Scorecard</font> and </font><font size="2"><font face="Courier New" color="#808080">Microsoft.BusinessIntelligence.Scorecard.Data</font>.
</font></font>
        </p>
        <p>
          <font face="Courier New">
            <font color="#808080">
              <font size="2">protected</font>
              <font size="2">
              </font>
              <font size="2">override</font>
              <font size="2">
              </font>
              <font size="2">void</font>
            </font>
          </font>
          <font face="Courier New">
            <font color="#808080">
              <font size="2"> RenderWebPart(HtmlTextWriter
output)<br />
{<br />
   </font>
            </font>
          </font>
          <font face="Courier New">
            <font color="#808080">
              <font size="2">
                <font face="Verdana" color="#000000">
                  <font face="Courier New">
                    <font color="#808080">
                      <font size="2">bool</font>
                      <font size="2"> header
= </font>
                      <font size="2">true</font>
                    </font>
                  </font>
                  <font size="2">
                    <font face="Courier New" color="#808080">;</font>
                  </font>
                </font>
              </font>
            </font>
          </font>
        </p>
        <p>
First we retrieve the instance to the IScorecardManager interface. Through this
interface a lot of methods can be used to get data from the cubicle to define
and/or calculate KPI values.
</p>
        <font size="2">
          <p>
            <font face="Courier New" color="#808080">   IScorecardManager mgr =
ScorecardManagerFactory.GetInstance();</font>
          </p>
          <p>
            <font face="Courier New" color="#808080">
              <font face="Verdana" color="#000000">Then
we use a data reader to get all defined SLA's for the customer. This will return
the SLACodes as strings. We check if there are any rows returned.<br /></font>
            </font>
            <font face="Courier New" color="#808080">
              <br />
   SqlDataReader reader = GetSLAs();<br /><br />
   </font>
          </p>
        </font>
        <font face="Courier New" color="#808080" size="2">try<br />
   </font>
        <font face="Courier New">
          <font color="#808080">
            <font size="2">{<br />
      </font>
            <font size="2">if</font>
            <font size="2"> (reader
== </font>
            <font size="2">null</font>
          </font>
        </font>
        <font face="Courier New" color="#808080" size="2">)<br />
      </font>
        <font face="Courier New">
          <font color="#808080">
            <font size="2">{<br /></font>
            <font size="2">         output.WriteLine(</font>
            <font size="2">"&lt;br&gt;&lt;br&gt;No
SLA's found for customer"</font>
          </font>
        </font>
        <font face="Courier New">
          <font color="#808080">
            <font size="2"> +
SLACode);<br />
         </font>
            <font size="2">return</font>
          </font>
        </font>
        <font size="2">
          <font face="Courier New" color="#808080">;<br />
      }</font>
          <p>
          </p>
        </font>
        <font face="Courier New" color="#808080" size="2">      if</font>
        <font face="Courier New" color="#808080" size="2"> (!reader.HasRows)<br />
      {<br />
         reader.Close();</font>
        <p>
          <font face="Courier New">
            <font color="#808080">
              <font size="2">         output.Write(</font>
              <font size="2">"There
are no SLA's defined."</font>
            </font>
          </font>
          <font face="Courier New">
            <font color="#808080">
              <font size="2">);<br />
         </font>
              <font size="2">return</font>
            </font>
          </font>
          <font size="2">
            <font face="Courier New" color="#808080">;<br />
      }</font>
          </font>
        </p>
        <p>
          <font size="2">
            <font color="#000000">We render a table to the client with some styles
defined in SharePoint and start looping through the found SLA's.</font>
          </font>
        </p>
        <p>
          <font face="Courier New" color="#808080">      output.WriteLine(</font>
          <font face="Courier New" color="#808080" size="2">"&lt;table
class=\"ms-summarycustombody\" width=100% cellpadding=\"2\" cellspacing=\"2\" border=\"0\"
style=\"margin-top: 3px;margin-left: 3px;margin-right: 3px;\"&gt;"</font>
          <font size="2">
            <font face="Courier New" color="#808080">);</font>
          </font>
        </p>
        <p>
          <font face="Courier New" color="#808080" size="2">      while</font>
          <font face="Courier New" color="#808080" size="2">(reader.Read()) <br />
      </font>
          <font face="Courier New">
            <font color="#808080">
              <font size="2">{<br />
         </font>
              <font size="2">string</font>
              <font size="2"> SLACode
= reader[</font>
              <font size="2">"sla_code"</font>
            </font>
          </font>
          <font face="Courier New">
            <font color="#808080">
              <font size="2">].ToString();<br /></font>
            </font>
          </font>
          <font size="2">
          </font>
        </p>
        <p>
          <font face="Courier New" color="#808080">         KpiValueRoot
root = </font>
          <font face="Courier New" color="#808080" size="2">null</font>
          <font size="2">
            <font face="Courier New" color="#808080">;</font>
          </font>
        </p>
        <p>
          <font size="2">
            <font color="#000000">The method GetSliceDefCollection returns a <font face="Courier New" color="#808080">SliceDefCollection</font> representing
a slice in the cubicle. Based on the ScorecardID and the collection the data is queried
for determining the KPI values. The ScorecardID can be retrieved from the BusinessScorecard
database. The method QueryAllKPIData uses the defined KPI's in the "Scorecard Development
Site" to retrieve per KPI the value.</font>
          </font>
        </p>
        <p>
          <font size="2">
            <font color="#000000">In this case we defined several KPI's for the
management parts named Sys,Prj,ASM,WRK,CON and TST. For each of them the data
is retrieved from the cubicle and represented as a value as specified in the properties
of the KPI. (see "Scorecard Development Site").</font>
          </font>
        </p>
        <p>
          <font face="Courier New" color="#808080" size="2">         try<br />
         </font>
          <font face="Courier New">
            <font color="#808080">
              <font size="2">{<br />
            root = mgr.QueryAllKpiData(MyConfiguration.ScorecardID,
GetSliceDefCollection(SLACode));<br />
         }<br />
         </font>
              <font size="2">catch</font>
            </font>
          </font>
          <font face="Courier New" color="#808080" size="2">(Exception)<br />
         {<br />
         </font>
          <font size="2">
            <font face="Courier New" color="#808080">}</font>
          </font>
        </p>
        <p>
          <font size="2">
            <font color="#000000">The first time in the loop we check if already
an header is rendered to the client. The header contains all short names of the management
parts for which KPI's are defined.</font>
          </font>
        </p>
        <p>
          <font face="Courier New" color="#808080" size="2">         if</font>
          <font face="Courier New">
            <font color="#808080">
              <font size="2"> (header)<br />
         {<br />
            output.WriteLine(</font>
              <font size="2">"&lt;tr&gt;"</font>
            </font>
          </font>
          <font face="Courier New">
            <font color="#808080">
              <font size="2">);<br />
            output.WriteLine(</font>
              <font size="2">"&lt;td
Class=\"ms-vb\"&gt;&lt;b&gt;SLA&lt;/b&gt;&lt;/td&gt;"</font>
            </font>
          </font>
          <font size="2">
            <font face="Courier New" color="#808080">);</font>
          </font>
        </p>
        <p>
          <font face="Courier New">
            <font color="#808080">
              <font size="2">            if</font>
              <font size="2"> (root
!= </font>
              <font size="2">null</font>
            </font>
          </font>
          <font face="Courier New">
            <font color="#808080">
              <font size="2">)<br />
            {<br />
               </font>
              <font size="2">for</font>
              <font size="2">(</font>
              <font size="2">int</font>
            </font>
          </font>
          <font face="Courier New">
            <font color="#808080">
              <font size="2"> index
= 0; index &lt; root.Children.Count; index++)<br />
               {<br />
                  output.WriteLine(</font>
              <font size="2">"&lt;td
Class=\"ms-vb\" align=center&gt;&lt;b&gt;"</font>
            </font>
          </font>
          <font face="Courier New">
            <font color="#808080">
              <font size="2">);<br />
                  output.WriteLine(GetShortManagementName(index
+ 1));<br />
                  output.WriteLine(</font>
              <font size="2">"&lt;/b&gt;&lt;/td&gt;"</font>
            </font>
          </font>
          <font size="2">
            <font face="Courier New" color="#808080">);<br />
               }<br />
            }</font>
          </font>
        </p>
        <p>
          <font face="Courier New" color="#808080">            output.WriteLine(</font>
          <font face="Courier New" color="#808080" size="2">"&lt;/tr&gt;"</font>
          <font size="2">
            <font face="Courier New" color="#808080">);</font>
          </font>
        </p>
        <p>
          <font face="Courier New" color="#808080">            header
= </font>
          <font face="Courier New" color="#808080" size="2">false</font>
          <font size="2">
            <font face="Courier New" color="#808080">;<br />
         }</font>
          </font>
        </p>
        <p>
          <font face="Courier New" color="#808080">         output.WriteLine(</font>
          <font face="Courier New" color="#808080" size="2">"&lt;tr&gt;"</font>
          <font face="Courier New">
            <font color="#808080">
              <font size="2">);<br />
         output.WriteLine(</font>
              <font size="2">"&lt;td
Class=\"ms-vb\"&gt;"</font>
            </font>
          </font>
          <font size="2">
            <font face="Courier New" color="#808080">);</font>
          </font>
        </p>
        <p>
          <font face="Courier New">
            <font color="#808080">
              <font size="2">         string</font>
              <font size="2"> Url
= </font>
              <font size="2">SLACode + </font>
              <font size="2">"/default.aspx"</font>
            </font>
          </font>
          <font size="2">
            <font face="Courier New" color="#808080">;</font>
          </font>
        </p>
        <p>
          <font face="Courier New" color="#808080">         output.WriteLine(</font>
          <font face="Courier New">
            <font color="#808080">
              <font size="2">"&lt;a
href='"</font>
              <font size="2"> + Url + </font>
              <font size="2">"'&gt;"</font>
              <font size="2"> +
Unit + </font>
              <font size="2">":"</font>
              <font size="2"> + SLACode + </font>
              <font size="2">"&lt;/a&gt;"</font>
            </font>
          </font>
          <font size="2">
            <font face="Courier New" color="#808080">);</font>
          </font>
        </p>
        <p>
          <font face="Courier New">
            <font color="#808080">
              <font size="2">         if</font>
              <font size="2"> (root
== </font>
              <font size="2">null</font>
            </font>
          </font>
          <font face="Courier New">
            <font color="#808080">
              <font size="2">)<br />
         {<br />
            output.WriteLine(</font>
              <font size="2">"(No
SLA's found for this month)"</font>
            </font>
          </font>
          <font size="2">
            <font face="Courier New" color="#808080">);<br />
         }</font>
          </font>
        </p>
        <p>
          <font face="Courier New" color="#808080">         output.WriteLine(</font>
          <font face="Courier New" color="#808080" size="2">"&lt;/td&gt;"</font>
          <font size="2">
            <font face="Courier New" color="#808080">);</font>
          </font>
        </p>
        <p>
          <font face="Courier New">
            <font color="#808080">
              <font size="2">         if</font>
              <font size="2"> (root
!= </font>
              <font size="2">null</font>
            </font>
          </font>
          <font face="Courier New">
            <font color="#808080">
              <font size="2">)<br />
         {</font>
            </font>
          </font>
        </p>
        <p>
          <font face="Courier New">
            <font color="#808080">
              <font size="2">
                <font face="Verdana" color="#000000">The
returned <font face="Courier New" color="#808080">KPIValueRoot</font> contains
the <font face="Courier New" color="#808080">KPIValue</font> objects as its children. We
loop through the children and based on the values in the <font color="#808080">KPIValue</font> object
we show the status image. As an alternating text the normalized band value is shown.
The <font face="Courier New" color="#808080">KPIValue</font> object contains a property
called <font face="Courier New" color="#808080">InBand</font> which can be used as
an index for the status image found in the<font color="#808080"><font face="Courier New">_layouts/../Scorecard/Images</font></font> folder.</font>
              </font>
            </font>
          </font>
        </p>
        <p>
          <font face="Courier New">
            <font color="#808080">
              <font size="2">
                <font face="Verdana" color="#000000">
                </font>
                <br />
            </font>
              <font size="2">foreach</font>
              <font size="2">(KpiValue
val </font>
              <font size="2">in</font>
            </font>
          </font>
          <font face="Courier New">
            <font color="#808080">
              <font size="2"> root.Children)<br />
            {<br />
               output.WriteLine(</font>
              <font size="2">"&lt;td
Class=\"ms-vb\" align=center&gt;"</font>
            </font>
          </font>
          <font size="2">
            <font face="Courier New" color="#808080">);</font>
          </font>
        </p>
        <p>
          <font face="Courier New" color="#808080">               Image
img = </font>
          <font face="Courier New" color="#808080" size="2">new</font>
          <font face="Courier New">
            <font color="#808080">
              <font size="2"> Image();<br />
               img.AlternateText
= val.NormalizedBandValue.ToString() + </font>
              <font size="2">"%"</font>
            </font>
          </font>
          <font face="Courier New">
            <font color="#808080">
              <font size="2">;<br />
               img.ImageUrl
= </font>
              <font size="2">"_layouts/"</font>
            </font>
          </font>
          <font face="Courier New">
            <font color="#808080">
              <font size="2"> + <br />
                   System.Threading.Thread.CurrentThread.CurrentUICulture.LCID.ToString()
+ <br />
                   </font>
              <font size="2">"/Scorecard/Images/Indicator5DefaultBand"</font>
              <font size="2"> +
val.InBand + </font>
              <font size="2">".gif"</font>
            </font>
          </font>
          <font size="2">
            <font face="Courier New" color="#808080">;</font>
          </font>
        </p>
        <p>
          <font face="Courier New" color="#808080">               Controls.Add(img);<br />
               img.RenderControl(output);</font>
        </p>
        <p>
          <font face="Courier New" color="#808080">               output.WriteLine(</font>
          <font face="Courier New" color="#808080" size="2">"&lt;/td&gt;"</font>
          <font size="2">
            <font face="Courier New" color="#808080">);<br />
            }<br />
         }</font>
          </font>
        </p>
        <p>
          <font face="Courier New" color="#808080">         output.WriteLine(</font>
          <font face="Courier New" color="#808080" size="2">"&lt;/tr&gt;"</font>
          <font size="2">
            <font face="Courier New" color="#808080">);<br />
      }</font>
          </font>
        </p>
        <p>
          <font face="Courier New" color="#808080">      output.WriteLine(</font>
          <font face="Courier New" color="#808080" size="2">"&lt;/table&gt;"</font>
          <font face="Courier New">
            <font color="#808080">
              <font size="2">);<br />
   }<br />
   </font>
              <font size="2">catch</font>
            </font>
          </font>
          <font face="Courier New" color="#808080" size="2">(Exception)<br />
   {<br />
   }<br />
   </font>
          <font face="Courier New" color="#808080" size="2">finally<br />
   </font>
          <font size="2">
            <font face="Courier New" color="#808080">{<br />
      reader.Close();<br />
   }<br />
}</font>
          </font>
        </p>
        <img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=2a1bbac3-4bf9-4e55-bbe2-2b9c61058071" />
      </body>
      <title>Custom WebPart using Microsoft Office Business Scorecard Accelerator API</title>
      <guid isPermaLink="false">http://net.bloggix.com/PermaLink,guid,2a1bbac3-4bf9-4e55-bbe2-2b9c61058071.aspx</guid>
      <link>http://net.bloggix.com/2005/05/24/CustomWebPartUsingMicrosoftOfficeBusinessScorecardAcceleratorAPI.aspx</link>
      <pubDate>Tue, 24 May 2005 12:37:10 GMT</pubDate>
      <description>&lt;font size=2&gt; 
&lt;p&gt;
For one of our customers we needed a specific overview of their KPI's&amp;nbsp;(Key Perfomance
Indicators) per defined SLA (Service Level Agreement). The standard Web Parts deliverd
by MOBSA (Microsoft Office Business Scorecard Accelerator)&amp;nbsp;were not providing
enough possibilities. We decided to build our own custom Web Part using the MOBSA
API. It is a very powerfull API and in this example we use it for showing multiple
KPI statuses&amp;nbsp;per defined SLA.
&lt;/font&gt;&gt;
&lt;p&gt;
&lt;font color=#0000ff size=2&gt;&lt;img src="http://blogs.tamtam.nl/alexander/content/binary/sla_overview.jpg" border=0&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;There are some methods used in the example for which no code is
deliverd. I will give a short explanation per method and their return values. The
property SLACode is actually a Site property keeping the name of the SLA of the customer.
Each customer has its own site in the SharePoint Portal.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;The method GetSliceDefCollection returns a &lt;font size=2&gt;&lt;font face="Courier New" color=#808080&gt;SliceDefCollection&lt;/font&gt; collection
class containing different slices of values used by the &lt;font face="Courier New" color=#808080&gt;QueryAllKPIData&lt;/font&gt; to
retrieve the correct slice from the cubicle. The slices represent Shared Dimensions
in SQL Analysis Server. An example could be something like this:&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;font color=#000000&gt;&lt;font size=2&gt;&lt;font size=2&gt; 
&lt;p&gt;
&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt;private&lt;/font&gt;&lt;font size=2&gt; SliceDefCollection
GetSliceDefCollection(string SLACode&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt;)&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font size=2&gt;SliceDefCollection sliceDefs = &lt;/font&gt;&lt;font size=2&gt;new&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New" color=#808080&gt; SliceDefCollection();&lt;/font&gt;&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;SliceDef def = &lt;/font&gt;
&lt;/font&gt;&lt;font face="Courier New" color=#808080 size=2&gt;new&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt; SliceDef();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;def.Slice = &lt;/font&gt;&lt;font size=2&gt;"[Time].[2005&lt;/font&gt;&lt;font size=2&gt;].[januari&lt;/font&gt;&lt;font size=2&gt;]"&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New" color=#808080&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;sliceDefs.Add(def);&lt;/font&gt;&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;def = &lt;/font&gt;
&lt;/font&gt;&lt;font face="Courier New" color=#808080 size=2&gt;new&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt; SliceDef();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;def.Slice = &lt;/font&gt;&lt;font size=2&gt;"[SLACode].[" + SLACode + &lt;/font&gt;&lt;font size=2&gt;]"&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New" color=#808080&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;sliceDefs.Add(def);&lt;/font&gt;&gt;
&lt;p&gt;
&lt;/font&gt;&lt;font face="Courier New" color=#808080 size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New" color=#808080&gt; sliceDefs;&lt;br&gt;
}&lt;/font&gt;&lt;/font&gt;&gt;
&lt;p&gt;
&lt;font size=2&gt;&lt;font color=#000000&gt;Finally we also use a method &lt;/font&gt;&lt;font face="Courier New" color=#808080&gt;&lt;font color=#808080&gt;GetShortManagementName&lt;/font&gt;&lt;font face=Verdana color=#000000&gt; to
retrieve the management part names.&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;/font&gt;&lt;/font&gt;&gt; 
&lt;p&gt;
&lt;font color=#000000&gt;I have posted the method &lt;font face="Courier New" color=#808080&gt;RenderWebPart&lt;/font&gt; and
have put some comment between the code to explain what i'm doing. You need to reference
the &lt;font face="Courier New" color=#808080&gt;MSScoreCardWebParts&lt;/font&gt; assembly and
at the top of the code the namespaces &lt;font size=2&gt;&lt;font face="Courier New" color=#808080&gt;Microsoft.BusinessIntelligence.Scorecard&lt;/font&gt; and &lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New" color=#808080&gt;Microsoft.BusinessIntelligence.Scorecard.Data&lt;/font&gt;.
&lt;/p&gt;
&gt;&gt; 
&lt;p&gt;
&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt;protected&lt;/font&gt;&lt;font size=2&gt; &lt;/font&gt;&lt;font size=2&gt;override&lt;/font&gt;&lt;font size=2&gt; &lt;/font&gt;&lt;font size=2&gt;void&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt; RenderWebPart(HtmlTextWriter
output)&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt;&lt;font face=Verdana color=#000000&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt;bool&lt;/font&gt;&lt;font size=2&gt; header
= &lt;/font&gt;&lt;font size=2&gt;true&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New" color=#808080&gt;;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&gt;First&amp;nbsp;we retrieve the instance to the IScorecardManager interface. Through this
interface a lot of methods can be used to get data from the&amp;nbsp;cubicle to define
and/or calculate KPI values.&gt;
&lt;/p&gt;
&gt;&gt;&gt;&lt;font size=2&gt; 
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;IScorecardManager mgr = ScorecardManagerFactory.GetInstance();&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;&lt;font face=Verdana color=#000000&gt;Then we use
a&amp;nbsp;data reader to get all defined SLA's for the customer. This will return the
SLACodes as strings. We check if there are any rows returned.&lt;br&gt;
&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New" color=#808080&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;SqlDataReader reader = GetSLAs();&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;
&lt;/font&gt;&lt;font face="Courier New" color=#808080 size=2&gt;try&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font size=2&gt;if&lt;/font&gt;&lt;font size=2&gt; (reader
== &lt;/font&gt;&lt;font size=2&gt;null&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New" color=#808080 size=2&gt;)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt;{&lt;br&gt;
&lt;/font&gt;&lt;font size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;output.WriteLine(&lt;/font&gt;&lt;font size=2&gt;"&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;No
SLA's found for customer"&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt; +
SLACode);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font size=2&gt;return&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New" color=#808080&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/font&gt;&gt;
&lt;p&gt;
&lt;/font&gt;&lt;font face="Courier New" color=#808080 size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if&lt;/font&gt;&lt;font face="Courier New" color=#808080 size=2&gt; (!reader.HasRows)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;reader.Close();&lt;/font&gt;&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;output.Write(&lt;/font&gt;&lt;font size=2&gt;"There
are no SLA's defined."&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt;);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font size=2&gt;return&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New" color=#808080&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font size=2&gt;&lt;font color=#000000&gt;We render a table to the client with some styles
defined in SharePoint and start looping through the found SLA's.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;output.WriteLine(&lt;/font&gt;&gt;&lt;font face="Courier New" color=#808080 size=2&gt;"&amp;lt;table
class=\"ms-summarycustombody\" width=100% cellpadding=\"2\" cellspacing=\"2\" border=\"0\"
style=\"margin-top: 3px;margin-left: 3px;margin-right: 3px;\"&amp;gt;"&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New" color=#808080&gt;);&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&gt;&lt;font face="Courier New" color=#808080 size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;while&lt;/font&gt;&lt;font face="Courier New" color=#808080 size=2&gt;(reader.Read())&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font size=2&gt;string&lt;/font&gt;&lt;font size=2&gt; SLACode
= reader[&lt;/font&gt;&lt;font size=2&gt;"sla_code"&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt;].ToString();&lt;br&gt;
&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;KpiValueRoot
root = &lt;/font&gt;&gt;&lt;font face="Courier New" color=#808080 size=2&gt;null&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New" color=#808080&gt;;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font size=2&gt;&lt;font color=#000000&gt;The method GetSliceDefCollection returns a &lt;font face="Courier New" color=#808080&gt;SliceDefCollection&lt;/font&gt; representing
a slice in the cubicle. Based on the ScorecardID and the collection the data is queried
for determining the KPI values. The ScorecardID can be retrieved from the BusinessScorecard
database. The method QueryAllKPIData uses the defined KPI's in the "Scorecard Development
Site" to retrieve per KPI the value.&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font size=2&gt;&lt;font color=#000000&gt;In this case we defined several KPI's for the management
parts&amp;nbsp;named Sys,Prj,ASM,WRK,CON and TST. For each of them the data is retrieved
from the cubicle and represented as a value as specified in the properties of the
KPI. (see "Scorecard Development Site").&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&gt;&lt;font face="Courier New" color=#808080 size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;try&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;root = mgr.QueryAllKpiData(MyConfiguration.ScorecardID,
GetSliceDefCollection(SLACode));&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font size=2&gt;catch&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New" color=#808080 size=2&gt;(Exception)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New" color=#808080&gt;}&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font size=2&gt;&lt;font color=#000000&gt;The first time in the loop we check if already an
header is rendered to the client. The header contains all short names of the management
parts for which KPI's are defined.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&gt;&lt;font face="Courier New" color=#808080 size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt; (header)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;output.WriteLine(&lt;/font&gt;&lt;font size=2&gt;"&amp;lt;tr&amp;gt;"&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt;);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;output.WriteLine(&lt;/font&gt;&lt;font size=2&gt;"&amp;lt;td
Class=\"ms-vb\"&amp;gt;&amp;lt;b&amp;gt;SLA&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;"&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New" color=#808080&gt;);&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if&lt;/font&gt;&lt;font size=2&gt; (root
!= &lt;/font&gt;&lt;font size=2&gt;null&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt;)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font size=2&gt;for&lt;/font&gt;&lt;font size=2&gt;(&lt;/font&gt;&lt;font size=2&gt;int&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt; index
= 0; index &amp;lt; root.Children.Count; index++)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;output.WriteLine(&lt;/font&gt;&lt;font size=2&gt;"&amp;lt;td
Class=\"ms-vb\" align=center&amp;gt;&amp;lt;b&amp;gt;"&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt;);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;output.WriteLine(GetShortManagementName(index
+ 1));&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;output.WriteLine(&lt;/font&gt;&lt;font size=2&gt;"&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;"&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New" color=#808080&gt;);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;output.WriteLine(&lt;/font&gt;&gt;&lt;font face="Courier New" color=#808080 size=2&gt;"&amp;lt;/tr&amp;gt;"&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New" color=#808080&gt;);&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;header
= &lt;/font&gt;&gt;&lt;font face="Courier New" color=#808080 size=2&gt;false&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New" color=#808080&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;output.WriteLine(&lt;/font&gt;&gt;&lt;font face="Courier New" color=#808080 size=2&gt;"&amp;lt;tr&amp;gt;"&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt;);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;output.WriteLine(&lt;/font&gt;&lt;font size=2&gt;"&amp;lt;td
Class=\"ms-vb\"&amp;gt;"&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New" color=#808080&gt;);&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;string&lt;/font&gt;&lt;font size=2&gt; Url
= &lt;/font&gt;&lt;font size=2&gt;SLACode + &lt;/font&gt;&lt;font size=2&gt;"/default.aspx"&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New" color=#808080&gt;;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;output.WriteLine(&lt;/font&gt;&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt;"&amp;lt;a
href='"&lt;/font&gt;&lt;font size=2&gt; + Url + &lt;/font&gt;&lt;font size=2&gt;"'&amp;gt;"&lt;/font&gt;&lt;font size=2&gt; +
Unit + &lt;/font&gt;&lt;font size=2&gt;":"&lt;/font&gt;&lt;font size=2&gt; + SLACode + &lt;/font&gt;&lt;font size=2&gt;"&amp;lt;/a&amp;gt;"&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New" color=#808080&gt;);&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if&lt;/font&gt;&lt;font size=2&gt; (root
== &lt;/font&gt;&lt;font size=2&gt;null&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt;)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;output.WriteLine(&lt;/font&gt;&lt;font size=2&gt;"(No
SLA's found for this month)"&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New" color=#808080&gt;);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;output.WriteLine(&lt;/font&gt;&gt;&lt;font face="Courier New" color=#808080 size=2&gt;"&amp;lt;/td&amp;gt;"&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New" color=#808080&gt;);&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if&lt;/font&gt;&lt;font size=2&gt; (root
!= &lt;/font&gt;&lt;font size=2&gt;null&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt;)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt;&lt;font face=Verdana color=#000000&gt;The
returned &lt;font face="Courier New" color=#808080&gt;KPIValueRoot&lt;/font&gt;&amp;nbsp;contains
the &lt;font face="Courier New" color=#808080&gt;KPIValue&lt;/font&gt; objects as its children.&amp;nbsp;We
loop through the children and based on the values in the &lt;font color=#808080&gt;KPIValue&lt;/font&gt; object
we show the status image. As an alternating text the normalized band value is shown.
The &lt;font face="Courier New" color=#808080&gt;KPIValue&lt;/font&gt; object contains a property
called &lt;font face="Courier New" color=#808080&gt;InBand&lt;/font&gt; which can be used as an
index for the status image found in the&lt;font color=#808080&gt; &lt;font face="Courier New"&gt;_layouts/../Scorecard/Images&lt;/font&gt;&lt;/font&gt; folder.&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt;&lt;font face=Verdana color=#000000&gt;&lt;/font&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font size=2&gt;foreach&lt;/font&gt;&lt;font size=2&gt;(KpiValue
val &lt;/font&gt;&lt;font size=2&gt;in&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt; root.Children)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;output.WriteLine(&lt;/font&gt;&lt;font size=2&gt;"&amp;lt;td
Class=\"ms-vb\" align=center&amp;gt;"&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New" color=#808080&gt;);&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Image
img = &lt;/font&gt;&gt;&lt;font face="Courier New" color=#808080 size=2&gt;new&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt; Image();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;img.AlternateText
= val.NormalizedBandValue.ToString() + &lt;/font&gt;&lt;font size=2&gt;"%"&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;img.ImageUrl
= &lt;/font&gt;&lt;font size=2&gt;"_layouts/"&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt; +&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;System.Threading.Thread.CurrentThread.CurrentUICulture.LCID.ToString()
+&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font size=2&gt;"/Scorecard/Images/Indicator5DefaultBand"&lt;/font&gt;&lt;font size=2&gt; +
val.InBand + &lt;/font&gt;&lt;font size=2&gt;".gif"&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New" color=#808080&gt;;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Controls.Add(img);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;img.RenderControl(output);&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;output.WriteLine(&lt;/font&gt;&gt;&lt;font face="Courier New" color=#808080 size=2&gt;"&amp;lt;/td&amp;gt;"&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New" color=#808080&gt;);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;output.WriteLine(&lt;/font&gt;&gt;&lt;font face="Courier New" color=#808080 size=2&gt;"&amp;lt;/tr&amp;gt;"&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New" color=#808080&gt;);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;output.WriteLine(&lt;/font&gt;&gt;&lt;font face="Courier New" color=#808080 size=2&gt;"&amp;lt;/table&amp;gt;"&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt;);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font size=2&gt;catch&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New" color=#808080 size=2&gt;(Exception)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font face="Courier New" color=#808080 size=2&gt;finally&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New" color=#808080&gt;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;reader.Close();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
}&lt;/font&gt;
&lt;/p&gt;
&gt;&lt;img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=2a1bbac3-4bf9-4e55-bbe2-2b9c61058071" /&gt;</description>
      <comments>http://net.bloggix.com/CommentView,guid,2a1bbac3-4bf9-4e55-bbe2-2b9c61058071.aspx</comments>
      <category>C#</category>
      <category>SharePoint</category>
    </item>
    <item>
      <trackback:ping>http://net.bloggix.com/Trackback.aspx?guid=ea7217d9-992e-4639-ab7b-91480c88260f</trackback:ping>
      <pingback:server>http://net.bloggix.com/pingback.aspx</pingback:server>
      <pingback:target>http://net.bloggix.com/PermaLink,guid,ea7217d9-992e-4639-ab7b-91480c88260f.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://net.bloggix.com/CommentView,guid,ea7217d9-992e-4639-ab7b-91480c88260f.aspx</wfw:comment>
      <wfw:commentRss>http://net.bloggix.com/SyndicationService.asmx/GetEntryCommentsRss?guid=ea7217d9-992e-4639-ab7b-91480c88260f</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <font size="2">
          <p>
            <font color="#000000">This weekend i needed a control to show jpeg images based on
a folder structure. I decided to create an <font face="Courier New" color="#808080">UserControl</font> and
used the <font face="Courier New" color="#808080">Table, TableRow, TableCell, LinkButton</font> and <font face="Courier New" color="#808080">Image</font> classes
for generating the view. You could also use a class derived from System.Web.UI.Control
and override the Render method for rendering the html.</font>
          </p>
          <p>
            <font color="#000000">This control is just an example of how to create your own <font face="Courier New" color="#000000">ImageFolderViewer</font> class.
It does not take into account that the images could be portrait or landscape format.
So if you need more functionality you have to make the additional changes yourself
or wait till i release a better version.</font>
          </p>
          <p>
            <font color="#000000">
              <img src="http://blogs.tamtam.nl/alexander/content/binary/imageviewer.jpg" border="0" />
            </font>
          </p>
          <p>
            <font color="#000000">The <font face="Courier New" color="#808080">ImageFolderViewer</font> class
contains three member variables defining the basic layout of the viewer. There is
a <font face="Courier New" color="#808080">horizontalImageCount</font> variable used
to define the maximum number of images per row. The <font face="Courier New" color="#808080">imageWidth </font>and <font face="Courier New" color="#808080">imageHeight</font> are
the width and height of the images in the viewer.</font>
          </p>
        </font>
        <p>
          <font face="Courier New">
            <font color="#808080">
              <font size="2">public</font>
              <font size="2">
              </font>
              <font size="2">class</font>
            </font>
          </font>
          <font face="Courier New">
            <font color="#808080">
              <font size="2"> ImageFolderViewer
: System.Web.UI.UserControl<br />
{<br />
   </font>
              <font size="2">int</font>
            </font>
          </font>
          <font face="Courier New">
            <font color="#808080">
              <font size="2"> horizontalImageCount
= 4;<br /></font>
              <font size="2">   int</font>
            </font>
          </font>
          <font face="Courier New">
            <font color="#808080">
              <font size="2"> imageWidth
= 120;<br /></font>
              <font size="2">   int</font>
            </font>
          </font>
          <font face="Courier New">
            <font color="#808080">
              <font size="2"> imageHeight
= 80;</font>
            </font>
          </font>
        </p>
        <p>
          <font face="Courier New">
            <font color="#808080">
              <font size="2">   ...<br />
}</font>
            </font>
          </font>
        </p>
        <p>
          <font face="Courier New">
            <font color="#808080">
              <font size="2">
                <font face="Verdana" color="#000000">In
the <font face="Courier New" color="#808080">Page_Load</font> of the class we call
the <font face="Courier New" color="#808080">GenerateImageView</font> method to generate
the images in the view.</font>
                <br />
                <br />
              </font>
              <font size="2">private</font>
              <font size="2">
              </font>
              <font size="2">void</font>
              <font size="2"> Page_Load(</font>
              <font size="2">object</font>
            </font>
          </font>
          <font size="2">
            <font face="Courier New" color="#808080"> sender,
System.EventArgs e)<br />
{<br />
   GenerateImageView();<br />
}</font>
          </font>
        </p>
        <p>
          <font size="2">
            <font color="#000000">The following property is used to set or get
the number of horizontal images per row.</font>
          </font>
        </p>
        <p>
          <font face="Courier New">
            <font color="#808080">
              <font size="2">public</font>
              <font size="2">
              </font>
              <font size="2">int</font>
            </font>
          </font>
          <font face="Courier New" color="#808080" size="2"> HorizontalImageCount<br />
{<br />
   </font>
          <font face="Courier New" color="#808080" size="2">get<br />
   </font>
          <font face="Courier New">
            <font color="#808080">
              <font size="2">{<br />
      </font>
              <font size="2">return</font>
            </font>
          </font>
          <font face="Courier New" color="#808080" size="2"> horizontalImageCount;<br />
   </font>
          <font face="Courier New" color="#808080" size="2">}<br />
   </font>
          <font face="Courier New" color="#808080" size="2">set<br />
   </font>
          <font face="Courier New">
            <font color="#808080">
              <font size="2">{<br />
      horizontalImageCount = </font>
              <font size="2">value</font>
            </font>
          </font>
          <font size="2">
            <font color="#808080">;<br />
   }<br />
}</font>
          </font>
        </p>
        <p>
          <font face="Courier New">
            <font color="#808080">
              <font size="2">
                <font face="Verdana" color="#000000">These
properties are used for remembering the current folder and the original folder
and are kept in the ViewState. The original folder is the first folder set to the
control. We use the original folder to define when i link is displayed
for moving a folder up.</font>  </font>
            </font>
          </font>
        </p>
        <p>
          <font face="Courier New">
            <font color="#808080">
              <font size="2">private </font>
              <font size="2">string</font>
            </font>
          </font>
          <font face="Courier New" color="#808080" size="2"> OriginalFolder<br />
{<br />
   </font>
          <font face="Courier New" color="#808080" size="2">get<br />
   </font>
          <font face="Courier New">
            <font color="#808080">
              <font size="2">{<br />
      </font>
              <font size="2">return</font>
              <font size="2"> ViewState[</font>
              <font size="2">"originalFolder"</font>
              <font size="2">]
!= </font>
              <font size="2">null</font>
              <font size="2"> ? ViewState[</font>
              <font size="2">"originalFolder"</font>
              <font size="2">].ToString()
: </font>
              <font size="2">""</font>
            </font>
          </font>
          <font face="Courier New" color="#808080" size="2">;<br />
   }<br />
   </font>
          <font face="Courier New" color="#808080" size="2">set<br />
   </font>
          <font face="Courier New">
            <font color="#808080">
              <font size="2">{<br />
      ViewState[</font>
              <font size="2">"originalFolder"</font>
              <font size="2">]
= </font>
              <font size="2">value</font>
            </font>
          </font>
          <font size="2">
            <font face="Courier New" color="#808080">;<br />
   }<br />
}</font>
          </font>
        </p>
        <p>
          <font face="Courier New">
            <font color="#808080">
              <font size="2">public</font>
              <font size="2">
              </font>
              <font size="2">string</font>
            </font>
          </font>
          <font face="Courier New" color="#808080" size="2"> Folder<br />
{<br />
   </font>
          <font face="Courier New" color="#808080" size="2">get<br />
   </font>
          <font face="Courier New">
            <font color="#808080">
              <font size="2">{<br />
      </font>
              <font size="2">return</font>
              <font size="2"> ViewState[</font>
              <font size="2">"folder"</font>
              <font size="2">]
!= </font>
              <font size="2">null</font>
              <font size="2"> ? ViewState[</font>
              <font size="2">"folder"</font>
              <font size="2">].ToString()
: </font>
              <font size="2">""</font>
            </font>
          </font>
          <font face="Courier New" color="#808080" size="2">;<br />
   }<br />
   </font>
          <font face="Courier New" color="#808080" size="2">set<br />
   </font>
          <font face="Courier New">
            <font color="#808080">
              <font size="2">{<br />
      // store the original folder in the viewstate</font>
            </font>
          </font>
          <font face="Courier New">
            <font color="#808080">
              <font size="2">
                <br />
      </font>
              <font size="2">if</font>
              <font size="2"> (OriginalFolder
== </font>
              <font size="2">""</font>
            </font>
          </font>
          <font face="Courier New">
            <font color="#808080">
              <font size="2">)<br />
      {<br />
         OriginalFolder = </font>
              <font size="2">value</font>
            </font>
          </font>
          <font size="2">
            <font face="Courier New" color="#808080">;<br />
      }</font>
          </font>
        </p>
        <p>
          <font face="Courier New" color="#808080">      ViewState[</font>
          <font face="Courier New">
            <font color="#808080">
              <font size="2">"folder"</font>
              <font size="2">]
= </font>
              <font size="2">value</font>
            </font>
          </font>
          <font size="2">
            <font face="Courier New" color="#808080">;<br />
   }<br />
}</font>
          </font>
        </p>
        <p>
          <font color="#000000">The <font face="Courier New" color="#808080">GenerateImageView</font> is
the engine of the class and generates all the images and subfolders. A seperate method <font face="Courier New" color="#808080">GenerateDirectoryLink</font> is
used for generating the link and its argument per subfolder.</font>
        </p>
        <p>
          <font face="Courier New">
            <font color="#808080">
              <font size="2">private</font>
              <font size="2">
              </font>
              <font size="2">void</font>
            </font>
          </font>
          <font face="Courier New">
            <font color="#808080">
              <font size="2"> GenerateImageView()<br />
{<br />
   </font>
              <font size="2">string</font>
            </font>
          </font>
          <font size="2">
            <font face="Courier New" color="#808080"> imagePath
= System.Web.HttpContext.Current.Server.MapPath(Folder);</font>
          </font>
        </p>
        <p>
          <font face="Courier New" color="#808080" size="2">   // check if the
folder exists<br />
   if</font>
          <font face="Courier New">
            <font color="#808080">
              <font size="2"> (!Directory.Exists(imagePath))<br />
   {<br />
      </font>
              <font size="2">return</font>
            </font>
          </font>
          <font size="2">
            <font face="Courier New" color="#808080">;<br />
   }</font>
          </font>
        </p>
        <font size="2">
          <p>
          </p>
        </font>
        <font face="Courier New">
          <font color="#808080">
            <font size="2">   string</font>
            <font size="2">[]
files = Directory.GetFiles(imagePath, </font>
            <font size="2">"*.jpg"</font>
          </font>
        </font>
        <font face="Courier New">
          <font color="#808080">
            <font size="2">);<br />
   </font>
            <font size="2">string</font>
          </font>
        </font>
        <font face="Courier New">
          <font color="#808080">
            <font size="2">[]
directories = Directory.GetDirectories(imagePath);<br />
   </font>
            <font size="2">int</font>
          </font>
        </font>
        <font size="2">
          <font face="Courier New" color="#808080"> hor
= 0;</font>
          <p>
            <font face="Courier New" color="#808080">   Controls.Clear();</font>
          </p>
          <p>
            <font face="Courier New" color="#808080">   Table tbl = </font>
          </p>
        </font>
        <font face="Courier New" color="#808080" size="2">new</font>
        <font size="2">
          <font face="Courier New" color="#808080"> Table();<br />
   Controls.Add(tbl);</font>
          <p>
          </p>
        </font>
        <font face="Courier New">
          <font color="#808080">
            <font size="2">   foreach</font>
            <font size="2">(</font>
            <font size="2">string</font>
            <font size="2"> dir </font>
            <font size="2">in</font>
          </font>
        </font>
        <font face="Courier New" color="#808080" size="2"> directories)<br />
   {<br />
      </font>
        <font size="2">
          <font face="Courier New" color="#808080">GenerateDirectoryLink(tbl,
Path.GetFileName(dir), <br />
             </font>
        </font>
        <font size="2">
          <font face="Courier New" color="#808080">Path.Combine(Folder,
Path.GetFileName(dir)));<br />
   }</font>
          <p>
          </p>
        </font>
        <font face="Courier New" color="#808080" size="2">   //
if it is not the original folder<br />
   // create a "Up one folder" link<br />
   if</font>
        <font face="Courier New">
          <font color="#808080">
            <font size="2"> (OriginalFolder
!= Folder)<br />
   {<br />
      GenerateDirectoryLink(tbl, </font>
            <font size="2">"Up
one folder"</font>
          </font>
        </font>
        <font size="2">
          <font face="Courier New" color="#808080">,
OriginalFolder);<br />
   }</font>
          <p>
            <font face="Courier New" color="#808080">   TableRow row = </font>
          </p>
        </font>
        <font face="Courier New" color="#808080" size="2">new</font>
        <font size="2">
          <font face="Courier New" color="#808080"> TableRow();<br />
   tbl.Controls.Add(row);</font>
          <p>
          </p>
        </font>
        <font face="Courier New">
          <font color="#808080">
            <font size="2">   foreach</font>
            <font size="2">(</font>
            <font size="2">string</font>
            <font size="2"> file </font>
            <font size="2">in</font>
          </font>
        </font>
        <font face="Courier New">
          <font color="#808080">
            <font size="2"> files)<br />
   {<br />
      // check if we already reached the end of the
row<br />
      // if so create a new row and reset the variable<br />
      </font>
            <font size="2">if</font>
          </font>
        </font>
        <font face="Courier New">
          <font color="#808080">
            <font size="2"> (hor
== HorizontalImageCount)<br />
      {<br />
         row = </font>
            <font size="2">new</font>
          </font>
        </font>
        <font size="2">
          <font face="Courier New" color="#808080"> TableRow();<br />
         tbl.Controls.Add(row);<br /><br />
         hor = 0;<br />
      }</font>
          <p>
            <font face="Courier New" color="#808080">      TableCell
cell = </font>
          </p>
        </font>
        <font face="Courier New" color="#808080" size="2">new</font>
        <font size="2">
          <font face="Courier New" color="#808080"> TableCell();<br />
      row.Controls.Add(cell);</font>
          <p>
          </p>
        </font>
        <font face="Courier New" color="#808080" size="2">      string</font>
        <font size="2">
          <font face="Courier New" color="#808080"> fileName
= Path.GetFileName(file);</font>
          <p>
            <font face="Courier New" color="#808080">      System.Web.UI.WebControls.Image
img = </font>
          </p>
        </font>
        <font face="Courier New" color="#808080" size="2">new</font>
        <font size="2">
          <font face="Courier New" color="#808080"> System.Web.UI.WebControls.Image();<br />
      img.ImageUrl = Path.Combine(imagePath, fileName);<br />
      img.AlternateText = fileName;<br />
      img.Width = imageWidth;<br />
      img.Height = imageHeight;<br />
      img.BorderWidth = 0;<br />
      cell.Controls.Add(img);</font>
          <p>
            <font face="Courier New" color="#808080">      hor++;<br />
   }<br />
}</font>
          </p>
          <p>
          </p>
        </font>
        <font face="Courier New">
          <font color="#808080">
            <font size="2">private</font>
            <font size="2">
            </font>
            <font size="2">void</font>
            <font size="2"> GenerateDirectoryLink(Table
parent, </font>
            <font size="2">string</font>
            <font size="2"> text, </font>
            <font size="2">string</font>
          </font>
        </font>
        <font face="Courier New">
          <font color="#808080">
            <font size="2"> argument)<br />
{<br />
   TableRow row = </font>
            <font size="2">new</font>
          </font>
        </font>
        <font face="Courier New" color="#808080" size="2"> TableRow();<br />
   parent.Controls.Add(row);</font>
        <p>
          <font face="Courier New">
            <font color="#808080">
              <font size="2">   TableCell
cell = </font>
              <font size="2">new</font>
            </font>
          </font>
          <font size="2">
            <font face="Courier New" color="#808080"> TableCell();<br />
   row.Controls.Add(cell);<br />
   cell.ColumnSpan = HorizontalImageCount;</font>
          </font>
        </p>
        <p>
          <font face="Courier New" color="#808080">   LinkButton btn = </font>
          <font face="Courier New" color="#808080" size="2">new</font>
          <font face="Courier New">
            <font color="#808080">
              <font size="2"> LinkButton();<br />
   btn.Text = text;<br />
   btn.CommandArgument = argument;<br />
   btn.Click += </font>
              <font size="2">new</font>
            </font>
          </font>
          <font face="Courier New" color="#808080" size="2"> EventHandler(FolderButton_Click);<br />
   </font>
          <font size="2">
            <font color="#808080">cell.Controls.Add(btn);<br />
}</font>
          </font>
        </p>
        <p>
          <font face="Courier New">
            <font color="#808080">
              <font size="2">
                <font face="Verdana" color="#000000">When
a link of a subfolder or "One folder up" is pressed an event is fired.
The <font face="Courier New" color="#808080">Folder</font> property is set to
the new folder and the view is generated again.</font> </font>
            </font>
          </font>
        </p>
        <p>
          <font face="Courier New">
            <font color="#808080">
              <font size="2">private</font>
              <font size="2">
              </font>
              <font size="2">void</font>
              <font size="2"> FolderButton_Click(</font>
              <font size="2">object</font>
            </font>
          </font>
          <font face="Courier New">
            <font color="#808080">
              <font size="2"> sender,
EventArgs e)<br />
{<br />
   LinkButton btn = sender </font>
              <font size="2">as</font>
            </font>
          </font>
          <font size="2">
            <font face="Courier New" color="#808080"> LinkButton;</font>
          </font>
        </p>
        <p>
          <font face="Courier New" color="#808080">   Folder = btn.CommandArgument;</font>
        </p>
        <p>
          <font face="Courier New" color="#808080">   GenerateImageView();<br />
}</font>
        </p>
        <p>
          <font color="#000000">Another problem is that if the images are large it will take
some time to place them in the view. There are several solutions for this problem.</font>
        </p>
        <ul>
          <li>
            <font color="#000000">You could create a thumbnail per image and refer the Image class
to the thumbnail instead. The thumbnail is only generated once. So it will only be
slow the first time</font>
          </li>
          <li>
            <font color="#000000">Use a third-party tool like ASPJPeg which does the resizing
for you.</font>
          </li>
        </ul>
        <p>
          <font color="#000000">Ofcourse there are more solutions but i thought that these two
would be nice to tell about.</font>
        </p>
        <p>
 
</p>
        <img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=ea7217d9-992e-4639-ab7b-91480c88260f" />
      </body>
      <title>ImageFolderViewer class for viewing images in a folder structure</title>
      <guid isPermaLink="false">http://net.bloggix.com/PermaLink,guid,ea7217d9-992e-4639-ab7b-91480c88260f.aspx</guid>
      <link>http://net.bloggix.com/2005/05/23/ImageFolderViewerClassForViewingImagesInAFolderStructure.aspx</link>
      <pubDate>Mon, 23 May 2005 08:36:26 GMT</pubDate>
      <description>&lt;font size=2&gt; 
&lt;p&gt;
&lt;font color=#000000&gt;This weekend i needed a control to show jpeg images based on a
folder structure. I decided to create an &lt;font face="Courier New" color=#808080&gt;UserControl&lt;/font&gt; and
used the &lt;font face="Courier New" color=#808080&gt;Table, TableRow, TableCell, LinkButton&lt;/font&gt; and &lt;font face="Courier New" color=#808080&gt;Image&lt;/font&gt; classes
for generating the view. You could also use a class derived from System.Web.UI.Control
and override the Render method for rendering the html.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;This control is just an example of how to create your own &lt;font face="Courier New" color=#000000&gt;ImageFolderViewer&lt;/font&gt; class.
It does not take into account that the images could be portrait or landscape format.
So if you need more functionality you have to make the additional changes yourself
or wait till i release a better version.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;&lt;img src="http://blogs.tamtam.nl/alexander/content/binary/imageviewer.jpg" border=0&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;The &lt;font face="Courier New" color=#808080&gt;ImageFolderViewer&lt;/font&gt; class
contains three member variables defining the basic layout of the viewer. There is
a &lt;font face="Courier New" color=#808080&gt;horizontalImageCount&lt;/font&gt; variable used
to define the maximum number of images per row. The &lt;font face="Courier New" color=#808080&gt;imageWidth &lt;/font&gt;and &lt;font face="Courier New" color=#808080&gt;imageHeight&lt;/font&gt; are
the width and height of the images in the viewer.&lt;/font&gt;
&lt;/font&gt;&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt;public&lt;/font&gt;&lt;font size=2&gt; &lt;/font&gt;&lt;font size=2&gt;class&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt; ImageFolderViewer
: System.Web.UI.UserControl&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font size=2&gt;int&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt; horizontalImageCount
= 4;&lt;br&gt;
&lt;/font&gt;&lt;font size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;int&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt; imageWidth
= 120;&lt;br&gt;
&lt;/font&gt;&lt;font size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;int&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt; imageHeight
= 80;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;...&lt;br&gt;
}&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt;&lt;font face=Verdana color=#000000&gt;In
the &lt;font face="Courier New" color=#808080&gt;Page_Load&lt;/font&gt; of the class we call the &lt;font face="Courier New" color=#808080&gt;GenerateImageView&lt;/font&gt; method
to generate the images in the view.&lt;/font&gt;
&lt;br&gt;
&lt;br&gt;
&lt;/font&gt;&lt;font size=2&gt;private&lt;/font&gt;&lt;font size=2&gt; &lt;/font&gt;&lt;font size=2&gt;void&lt;/font&gt;&lt;font size=2&gt; Page_Load(&lt;/font&gt;&lt;font size=2&gt;object&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New" color=#808080&gt; sender,
System.EventArgs e)&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;GenerateImageView();&lt;br&gt;
}&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font size=2&gt;&lt;font color=#000000&gt;The following property is used to set or get the
number of horizontal images&amp;nbsp;per row.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt;public&lt;/font&gt;&lt;font size=2&gt; &lt;/font&gt;&lt;font size=2&gt;int&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New" color=#808080 size=2&gt; HorizontalImageCount&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font face="Courier New" color=#808080 size=2&gt;get&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font size=2&gt;return&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New" color=#808080 size=2&gt; horizontalImageCount;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font face="Courier New" color=#808080 size=2&gt;}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font face="Courier New" color=#808080 size=2&gt;set&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;horizontalImageCount = &lt;/font&gt;&lt;font size=2&gt;value&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;font color=#808080&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt;&lt;font face=Verdana color=#000000&gt;These
properties are used for&amp;nbsp;remembering the current folder and the original folder
and are kept in the ViewState. The original folder is the first folder set to the
control.&amp;nbsp;We&amp;nbsp;use the original folder to define when i&amp;nbsp;link&amp;nbsp;is&amp;nbsp;displayed
for moving a folder up.&lt;/font&gt;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt;private &lt;/font&gt;&lt;font size=2&gt;string&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New" color=#808080 size=2&gt; OriginalFolder&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font face="Courier New" color=#808080 size=2&gt;get&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font size=2&gt;return&lt;/font&gt;&lt;font size=2&gt; ViewState[&lt;/font&gt;&lt;font size=2&gt;"originalFolder"&lt;/font&gt;&lt;font size=2&gt;]
!= &lt;/font&gt;&lt;font size=2&gt;null&lt;/font&gt;&lt;font size=2&gt; ? ViewState[&lt;/font&gt;&lt;font size=2&gt;"originalFolder"&lt;/font&gt;&lt;font size=2&gt;].ToString()
: &lt;/font&gt;&lt;font size=2&gt;""&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New" color=#808080 size=2&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font face="Courier New" color=#808080 size=2&gt;set&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ViewState[&lt;/font&gt;&lt;font size=2&gt;"originalFolder"&lt;/font&gt;&lt;font size=2&gt;]
= &lt;/font&gt;&lt;font size=2&gt;value&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New" color=#808080&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt;public&lt;/font&gt;&lt;font size=2&gt; &lt;/font&gt;&lt;font size=2&gt;string&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New" color=#808080 size=2&gt; Folder&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font face="Courier New" color=#808080 size=2&gt;get&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font size=2&gt;return&lt;/font&gt;&lt;font size=2&gt; ViewState[&lt;/font&gt;&lt;font size=2&gt;"folder"&lt;/font&gt;&lt;font size=2&gt;]
!= &lt;/font&gt;&lt;font size=2&gt;null&lt;/font&gt;&lt;font size=2&gt; ? ViewState[&lt;/font&gt;&lt;font size=2&gt;"folder"&lt;/font&gt;&lt;font size=2&gt;].ToString()
: &lt;/font&gt;&lt;font size=2&gt;""&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New" color=#808080 size=2&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font face="Courier New" color=#808080 size=2&gt;set&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// store the original folder in the viewstate&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font size=2&gt;if&lt;/font&gt;&lt;font size=2&gt; (OriginalFolder
== &lt;/font&gt;&lt;font size=2&gt;""&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt;)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;OriginalFolder = &lt;/font&gt;&lt;font size=2&gt;value&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New" color=#808080&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ViewState[&lt;/font&gt;&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt;"folder"&lt;/font&gt;&lt;font size=2&gt;]
= &lt;/font&gt;&lt;font size=2&gt;value&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New" color=#808080&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;The &lt;font face="Courier New" color=#808080&gt;GenerateImageView&lt;/font&gt; is
the engine of the class and generates all the images and subfolders. A seperate method &lt;font face="Courier New" color=#808080&gt;GenerateDirectoryLink&lt;/font&gt; is
used for generating the link and its argument per subfolder.&lt;/font&gt;&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt;private&lt;/font&gt;&lt;font size=2&gt; &lt;/font&gt;&lt;font size=2&gt;void&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt; GenerateImageView()&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font size=2&gt;string&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New" color=#808080&gt; imagePath
= System.Web.HttpContext.Current.Server.MapPath(Folder);&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080 size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// check if the folder&amp;nbsp;exists&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;if&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt; (!Directory.Exists(imagePath))&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font size=2&gt;return&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New" color=#808080&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;font size=2&gt; 
&lt;p&gt;
&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;string&lt;/font&gt;&lt;font size=2&gt;[]
files = Directory.GetFiles(imagePath, &lt;/font&gt;&lt;font size=2&gt;"*.jpg"&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt;);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font size=2&gt;string&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt;[]
directories = Directory.GetDirectories(imagePath);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font size=2&gt;int&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New" color=#808080&gt; hor
= 0;&lt;/font&gt;&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Controls.Clear();&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Table tbl = &lt;/font&gt;
&lt;/font&gt;&lt;font face="Courier New" color=#808080 size=2&gt;new&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New" color=#808080&gt; Table();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;Controls.Add(tbl);&lt;/font&gt;&gt;
&lt;p&gt;
&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;foreach&lt;/font&gt;&lt;font size=2&gt;(&lt;/font&gt;&lt;font size=2&gt;string&lt;/font&gt;&lt;font size=2&gt; dir &lt;/font&gt;&lt;font size=2&gt;in&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New" color=#808080 size=2&gt; directories)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New" color=#808080&gt;GenerateDirectoryLink(tbl,
Path.GetFileName(dir),&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New" color=#808080&gt;Path.Combine(Folder,
Path.GetFileName(dir)));&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/font&gt;&gt;
&lt;p&gt;
&lt;/font&gt;&lt;font face="Courier New" color=#808080 size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// if it is
not the original&amp;nbsp;folder&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;// create&amp;nbsp;a "Up one folder" link&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;if&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt; (OriginalFolder
!= Folder)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;GenerateDirectoryLink(tbl, &lt;/font&gt;&lt;font size=2&gt;"Up
one folder"&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New" color=#808080&gt;,
OriginalFolder);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/font&gt;&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;TableRow row = &lt;/font&gt;
&lt;/font&gt;&lt;font face="Courier New" color=#808080 size=2&gt;new&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New" color=#808080&gt; TableRow();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;tbl.Controls.Add(row);&lt;/font&gt;&gt;
&lt;p&gt;
&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;foreach&lt;/font&gt;&lt;font size=2&gt;(&lt;/font&gt;&lt;font size=2&gt;string&lt;/font&gt;&lt;font size=2&gt; file &lt;/font&gt;&lt;font size=2&gt;in&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt; files)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// check if we already reached the end of the
row&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// if so create a new row and reset the variable&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font size=2&gt;if&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt; (hor
== HorizontalImageCount)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;row = &lt;/font&gt;&lt;font size=2&gt;new&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New" color=#808080&gt; TableRow();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;tbl.Controls.Add(row);&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;hor = 0;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/font&gt;&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;TableCell
cell = &lt;/font&gt;
&lt;/font&gt;&lt;font face="Courier New" color=#808080 size=2&gt;new&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New" color=#808080&gt; TableCell();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;row.Controls.Add(cell);&lt;/font&gt;&gt;
&lt;p&gt;
&lt;/font&gt;&lt;font face="Courier New" color=#808080 size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;string&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New" color=#808080&gt; fileName
= Path.GetFileName(file);&lt;/font&gt;&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;System.Web.UI.WebControls.Image
img = &lt;/font&gt;
&lt;/font&gt;&lt;font face="Courier New" color=#808080 size=2&gt;new&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New" color=#808080&gt; System.Web.UI.WebControls.Image();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;img.ImageUrl = Path.Combine(imagePath, fileName);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;img.AlternateText = fileName;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;img.Width = imageWidth;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;img.Height = imageHeight;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;img.BorderWidth = 0;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cell.Controls.Add(img);&lt;/font&gt;&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;hor++;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt;private&lt;/font&gt;&lt;font size=2&gt; &lt;/font&gt;&lt;font size=2&gt;void&lt;/font&gt;&lt;font size=2&gt; GenerateDirectoryLink(Table
parent, &lt;/font&gt;&lt;font size=2&gt;string&lt;/font&gt;&lt;font size=2&gt; text, &lt;/font&gt;&lt;font size=2&gt;string&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt; argument)&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;TableRow row = &lt;/font&gt;&lt;font size=2&gt;new&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New" color=#808080 size=2&gt; TableRow();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;parent.Controls.Add(row);&lt;/font&gt;&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;TableCell
cell = &lt;/font&gt;&lt;font size=2&gt;new&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New" color=#808080&gt; TableCell();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;row.Controls.Add(cell);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;cell.ColumnSpan = HorizontalImageCount;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;LinkButton btn = &lt;/font&gt;&gt;&lt;font face="Courier New" color=#808080 size=2&gt;new&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt; LinkButton();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;btn.Text = text;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;btn.CommandArgument = argument;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;btn.Click += &lt;/font&gt;&lt;font size=2&gt;new&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New" color=#808080 size=2&gt; EventHandler(FolderButton_Click);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font size=2&gt;&lt;font color=#808080&gt;cell.Controls.Add(btn);&lt;br&gt;
}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt;&lt;font face=Verdana color=#000000&gt;When
a link&amp;nbsp;of a subfolder or&amp;nbsp;"One folder up" is pressed&amp;nbsp;an event is fired.
The &lt;font face="Courier New" color=#808080&gt;Folder&lt;/font&gt; property&amp;nbsp;is set to the
new&amp;nbsp;folder and the view is generated again.&lt;/font&gt;&amp;nbsp;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt;private&lt;/font&gt;&lt;font size=2&gt; &lt;/font&gt;&lt;font size=2&gt;void&lt;/font&gt;&lt;font size=2&gt; FolderButton_Click(&lt;/font&gt;&lt;font size=2&gt;object&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt; sender,
EventArgs e)&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;LinkButton btn = sender &lt;/font&gt;&lt;font size=2&gt;as&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New" color=#808080&gt; LinkButton;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Folder = btn.CommandArgument;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;GenerateImageView();&lt;br&gt;
}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;Another problem is that if the images are large it will take some
time to place them in the view. There are several solutions for this problem.&lt;/font&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;font color=#000000&gt;You could create a thumbnail per image and refer the Image class
to the thumbnail instead. The thumbnail is only generated once. So it will only be
slow the first time&lt;/font&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;font color=#000000&gt;Use a third-party tool like ASPJPeg which does the resizing for
you.&lt;/font&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
&lt;font color=#000000&gt;Ofcourse there are more solutions but i thought that these two
would be nice to tell about.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&gt;&lt;img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=ea7217d9-992e-4639-ab7b-91480c88260f" /&gt;</description>
      <comments>http://net.bloggix.com/CommentView,guid,ea7217d9-992e-4639-ab7b-91480c88260f.aspx</comments>
      <category>ASP.NET</category>
      <category>C#</category>
    </item>
    <item>
      <trackback:ping>http://net.bloggix.com/Trackback.aspx?guid=cf07e0b5-a70f-4f52-877a-47cfa0ec0cf3</trackback:ping>
      <pingback:server>http://net.bloggix.com/pingback.aspx</pingback:server>
      <pingback:target>http://net.bloggix.com/PermaLink,guid,cf07e0b5-a70f-4f52-877a-47cfa0ec0cf3.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://net.bloggix.com/CommentView,guid,cf07e0b5-a70f-4f52-877a-47cfa0ec0cf3.aspx</wfw:comment>
      <wfw:commentRss>http://net.bloggix.com/SyndicationService.asmx/GetEntryCommentsRss?guid=cf07e0b5-a70f-4f52-877a-47cfa0ec0cf3</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <font color="#000000">At <a href="http://weblogs.asp.net/rhoward/">Rob Howard's blog</a> we
can read that CodeSmith 3.0 has been released since Monday May 16th. I agree with
him that using code generation tools can save enormous time and prevents common mistakes
by writing the same code over and over again.</font>
        </p>
        <p>
          <em>
            <font color="#000000">"Code generation tools represent one of the most interesting
areas where a tremendous amount of innovation opportunity still exists for improving
the software development process. By automating the process of creating framework,
database access, or other common/repeated code patters developers can save time, companies
can save money, and users of the end product will get better solutions. Why? Instead
of spending hours repeating the same logic flows, data access layers, or implementation
frameworks just write it once as a CodeSmith template. That's right -- using .NET
code you can write a template for how you want your code to be generated. It's still
your code with your formatting your comments and your style -- CodeSmith just helps
you write it faster. In fact, you could say it's like hiring your own personal
army of developers!"</font>
          </em>
        </p>
        <p>
          <font color="#000000">You can download a <a href="http://www.codesmithtools.com/license.aspx">free
30 day trial version</a>.</font>
        </p>
        <p>
          <a href="http://weblogs.asp.net/rhoward/archive/2005/05/17/407197.aspx">http://weblogs.asp.net/rhoward/archive/2005/05/17/407197.aspx</a>
        </p>
        <img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=cf07e0b5-a70f-4f52-877a-47cfa0ec0cf3" />
      </body>
      <title>CodeSmith 3.0 Released!</title>
      <guid isPermaLink="false">http://net.bloggix.com/PermaLink,guid,cf07e0b5-a70f-4f52-877a-47cfa0ec0cf3.aspx</guid>
      <link>http://net.bloggix.com/2005/05/18/CodeSmith30Released.aspx</link>
      <pubDate>Wed, 18 May 2005 06:40:52 GMT</pubDate>
      <description>&lt;p&gt;
&lt;font color=#000000&gt;At &lt;a href="http://weblogs.asp.net/rhoward/"&gt;Rob Howard's blog&lt;/a&gt; we
can read that CodeSmith 3.0 has been released since Monday May 16th. I agree with
him that using code generation tools can save enormous time and prevents common mistakes
by writing the same code over and over again.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;em&gt;&lt;font color=#000000&gt;"Code generation tools&amp;nbsp;represent one of the most interesting
areas where a tremendous amount of innovation opportunity still exists for improving
the software development process. By automating the process of creating framework,
database access, or other common/repeated code patters developers can save time, companies
can save money, and users of the end product will get better solutions. Why? Instead
of spending hours repeating the same logic flows, data access layers, or implementation
frameworks just write it once as a CodeSmith template. That's right -- using .NET
code you can write a template for how you want your code to be generated. It's still
your code with your formatting your comments and your style -- CodeSmith just helps
you write it faster. In fact, you could say it's like&amp;nbsp;hiring your own personal
army of developers!"&lt;/font&gt;&lt;/em&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;You can download a &lt;a href="http://www.codesmithtools.com/license.aspx"&gt;free
30 day trial version&lt;/a&gt;.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://weblogs.asp.net/rhoward/archive/2005/05/17/407197.aspx"&gt;http://weblogs.asp.net/rhoward/archive/2005/05/17/407197.aspx&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=cf07e0b5-a70f-4f52-877a-47cfa0ec0cf3" /&gt;</description>
      <comments>http://net.bloggix.com/CommentView,guid,cf07e0b5-a70f-4f52-877a-47cfa0ec0cf3.aspx</comments>
      <category>.NET</category>
      <category>C#</category>
    </item>
    <item>
      <trackback:ping>http://net.bloggix.com/Trackback.aspx?guid=2cfef107-ea0b-4276-8be4-8acf30160811</trackback:ping>
      <pingback:server>http://net.bloggix.com/pingback.aspx</pingback:server>
      <pingback:target>http://net.bloggix.com/PermaLink,guid,2cfef107-ea0b-4276-8be4-8acf30160811.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://net.bloggix.com/CommentView,guid,2cfef107-ea0b-4276-8be4-8acf30160811.aspx</wfw:comment>
      <wfw:commentRss>http://net.bloggix.com/SyndicationService.asmx/GetEntryCommentsRss?guid=2cfef107-ea0b-4276-8be4-8acf30160811</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <font color="#000000">
            <a href="http://sqljunkies.com/WebLog/amachanic/">Adam Machanic</a> has
posted a month ago an article about SqlDataReader performance tips. One about using
an indexer with the ordinal position, a second one about avoiding the <font face="Courier New" color="#808080">Get&lt;datatype&gt;</font> methods
and a third about opening and closing the reader.</font>
        </p>
        <p>
          <font color="#000000">Especially the last one is something we all sometimes forget.
Thanks to Adam for these tips! :)</font>
        </p>
        <p>
          <font color="#000000">
            <strong>Tip 1: </strong>
          </font>
          <font color="#000000">
            <strong>Use
an indexer with the ordinal position</strong>: </font>
        </p>
        <p>
          <font color="#000000">Instead of: </font>
        </p>
        <p>
          <font color="#000000">
          </font>
        </p>
        <pre class="code">
          <font face="Verdana" color="#000000">
            <font face="Courier New" color="#808080">while
(reader.read()) object x = reader.GetValue("ColX");</font>
          </font>
        </pre>
        <p>
          <font color="#000000">or </font>
        </p>
        <p>
          <font color="#000000">
          </font>
        </p>
        <pre class="code">
          <font face="Verdana" color="#000000">
            <font color="#808080">while
(reader.read()) object x = reader["ColX"];</font>
          </font>
        </pre>
        <p>
          <font color="#000000">do: </font>
        </p>
        <p>
          <font color="#000000">
          </font>
        </p>
        <pre class="code">
          <font face="Verdana" color="#000000">
            <font face="Courier New" color="#808080">int
ColX = reader.GetOrdinal("ColX"); while (reader.read()) object x = reader[ColX];</font>
          </font>
        </pre>
        <p>
          <font color="#000000">
            <strong>Tip 2: Avoid the Get&lt;datatype&gt; (e.g. GetInt32)
methods at all costs, and use static casts instead of converts: </strong>
          </font>
        </p>
        <p>
          <font color="#000000">Bad: </font>
        </p>
        <pre class="code">
          <font face="Verdana" color="#000000">
            <font face="Courier New" color="#808080">int
x = reader.GetInt32(ColX);</font>
          </font>
        </pre>
        <p>
          <font color="#000000">Better: </font>
        </p>
        <p>
          <font color="#000000">
          </font>
        </p>
        <pre class="code">
          <font face="Verdana" color="#000000">
            <font face="Courier New" color="#808080">int
x = Convert.ToInt32(reader[ColX]);</font>
          </font>
        </pre>
        <p>
          <font color="#000000">Best: </font>
        </p>
        <p>
          <font color="#000000">
          </font>
        </p>
        <pre class="code">
          <font face="Verdana" color="#000000">
            <font face="Courier New" color="#808080">int
x = (int)reader[ColX];</font>
          </font>
        </pre>
        <p>
          <font color="#000000">For maximal performance return the SQL Server equivalent of
whatever datatype you'll be casting to (so that you can avoid the Convert methods.)
And avoid NULLs so that you don't have to check for DBNull on the client.</font>
        </p>
        <p>
          <font color="#000000">
            <strong>Tip 3: "open late and close early"</strong>
          </font>
        </p>
        <p>
          <font color="#000000">Finally, just like in classic ADO, when using a SqlDataReader,
"open late and close early" is the way to go. Open your connection at the last possible
moment and close it as soon as you're done reading the data -- this will maximize
connection pool availability. </font>
        </p>
        <p>
          <font color="#000000">
          </font> 
</p>
        <p>
          <font color="#000000">you can find all the tips also at his blog by following this
link:</font>
        </p>
        <p>
          <a href="http://sqljunkies.com/WebLog/amachanic/archive/2005/04/06/10462.aspx">http://sqljunkies.com/WebLog/amachanic/archive/2005/04/06/10462.aspx</a>
        </p>
        <img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=2cfef107-ea0b-4276-8be4-8acf30160811" />
      </body>
      <title>Nice SqlDataReader performance tips by Adam Machanic</title>
      <guid isPermaLink="false">http://net.bloggix.com/PermaLink,guid,2cfef107-ea0b-4276-8be4-8acf30160811.aspx</guid>
      <link>http://net.bloggix.com/2005/05/18/NiceSqlDataReaderPerformanceTipsByAdamMachanic.aspx</link>
      <pubDate>Wed, 18 May 2005 06:30:09 GMT</pubDate>
      <description>&lt;p&gt;
&lt;font color=#000000&gt;&lt;a href="http://sqljunkies.com/WebLog/amachanic/"&gt;Adam Machanic&lt;/a&gt; has
posted a month ago an article about SqlDataReader performance tips. One about using
an indexer with the ordinal position, a second one about avoiding the &lt;font face="Courier New" color=#808080&gt;Get&amp;lt;datatype&amp;gt;&lt;/font&gt; methods
and a third about opening and closing the reader.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;Especially the last one is something we all sometimes forget.
Thanks to Adam for these tips! :)&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;&lt;strong&gt;Tip 1: &lt;/strong&gt;&lt;/font&gt;&lt;font color=#000000&gt;&lt;strong&gt;Use
an indexer with the ordinal position&lt;/strong&gt;: &lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;Instead of: &lt;/font&gt; 
&lt;p&gt;
&lt;font color=#000000&gt;&lt;/font&gt;&lt;pre class=code&gt;&lt;font face=Verdana color=#000000&gt;&lt;font face="Courier New" color=#808080&gt;while
(reader.read()) object x = reader.GetValue("ColX");&lt;/font&gt; &lt;/font&gt;&lt;/pre&gt;
&lt;p&gt;
&lt;font color=#000000&gt;or &lt;/font&gt; 
&lt;p&gt;
&lt;font color=#000000&gt;&lt;/font&gt;&lt;pre class=code&gt;&lt;font face=Verdana color=#000000&gt;&lt;font color=#808080&gt;while
(reader.read()) object x = reader["ColX"];&lt;/font&gt; &lt;/font&gt;&lt;/pre&gt;
&lt;p&gt;
&lt;font color=#000000&gt;do: &lt;/font&gt; 
&lt;p&gt;
&lt;font color=#000000&gt;&lt;/font&gt;&lt;pre class=code&gt;&lt;font face=Verdana color=#000000&gt;&lt;font face="Courier New" color=#808080&gt;int
ColX = reader.GetOrdinal("ColX"); while (reader.read()) object x = reader[ColX];&lt;/font&gt; &lt;/font&gt;&lt;/pre&gt;
&lt;p&gt;
&lt;font color=#000000&gt;&lt;strong&gt;Tip 2: Avoid the Get&amp;lt;datatype&amp;gt; (e.g. GetInt32) methods
at all costs, and use static casts instead of converts: &lt;/strong&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;Bad: &lt;/font&gt;&lt;pre class=code&gt;&lt;font face=Verdana color=#000000&gt;&lt;font face="Courier New" color=#808080&gt;int
x = reader.GetInt32(ColX);&lt;/font&gt; &lt;/font&gt;&lt;/pre&gt;
&lt;p&gt;
&lt;font color=#000000&gt;Better: &lt;/font&gt; 
&lt;p&gt;
&lt;font color=#000000&gt;&lt;/font&gt;&lt;pre class=code&gt;&lt;font face=Verdana color=#000000&gt;&lt;font face="Courier New" color=#808080&gt;int
x = Convert.ToInt32(reader[ColX]);&lt;/font&gt; &lt;/font&gt;&lt;/pre&gt;
&lt;p&gt;
&lt;font color=#000000&gt;Best: &lt;/font&gt; 
&lt;p&gt;
&lt;font color=#000000&gt;&lt;/font&gt;&lt;pre class=code&gt;&lt;font face=Verdana color=#000000&gt;&lt;font face="Courier New" color=#808080&gt;int
x = (int)reader[ColX];&lt;/font&gt; &lt;/font&gt;&lt;/pre&gt;
&lt;p&gt;
&lt;font color=#000000&gt;For maximal performance return the SQL Server equivalent of whatever
datatype you'll be casting to (so that you can avoid the Convert methods.) And avoid
NULLs so that you don't have to check for DBNull on the client.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;&lt;strong&gt;Tip 3: "open late and close early"&lt;/strong&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;Finally, just like in classic ADO, when using a SqlDataReader,
"open late and close early" is the way to go. Open your connection at the last possible
moment and close it as soon as you're done reading the data -- this will maximize
connection pool availability. &lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;&lt;/font&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;you can find all the tips also at his blog by following this link:&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://sqljunkies.com/WebLog/amachanic/archive/2005/04/06/10462.aspx"&gt;http://sqljunkies.com/WebLog/amachanic/archive/2005/04/06/10462.aspx&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=2cfef107-ea0b-4276-8be4-8acf30160811" /&gt;</description>
      <comments>http://net.bloggix.com/CommentView,guid,2cfef107-ea0b-4276-8be4-8acf30160811.aspx</comments>
      <category>C#</category>
      <category>Databases</category>
    </item>
    <item>
      <trackback:ping>http://net.bloggix.com/Trackback.aspx?guid=ef822f4b-0f70-4cb9-afb7-e2e5099e01e1</trackback:ping>
      <pingback:server>http://net.bloggix.com/pingback.aspx</pingback:server>
      <pingback:target>http://net.bloggix.com/PermaLink,guid,ef822f4b-0f70-4cb9-afb7-e2e5099e01e1.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://net.bloggix.com/CommentView,guid,ef822f4b-0f70-4cb9-afb7-e2e5099e01e1.aspx</wfw:comment>
      <wfw:commentRss>http://net.bloggix.com/SyndicationService.asmx/GetEntryCommentsRss?guid=ef822f4b-0f70-4cb9-afb7-e2e5099e01e1</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <font color="#000000">Passing a null value to an int is not possible. The int type
is mapped to the System.Int32 structure type and is not capable of storing a null
value. Only integer values can be stored in there.</font>
        </p>
        <p>
          <font color="#000000">There are two ways which i know of how to solve this problem.
The first method is using an object in stead of the int type. For example:</font>
        </p>
        <p>
          <font face="Courier New" color="#808080">object val = 200;</font>
        </p>
        <p>
          <font face="Courier New" color="#808080">if (val != null)<br />
{<br />
   return (int)val;<br />
}<br /></font>
          <br />
          <font color="#000000">In this way you can set the <font face="Courier New" color="#808080">val</font> variable
to a null value or an integer value. In case of an integer value you unbox the value
to retrieve the integer value.</font>
        </p>
        <p>
          <font color="#000000">A second method is using the <font face="Courier New" color="#808080">SqlInt32</font> type
found in namespace <font face="Courier New" color="#808080">System.Data.SqlTypes</font> which
is a SQL type. This type supports nullable values. For example:</font>
        </p>
        <p>
          <font color="#808080">
            <font face="Courier New">SqlInt32 val = SqlInt32.Null;</font>
          </font>
        </p>
        <p>
          <font color="#000000">or</font>
        </p>
        <p>
          <font face="Courier New" color="#808080">SqlInt32 val = 200;</font>
        </p>
        <img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=ef822f4b-0f70-4cb9-afb7-e2e5099e01e1" />
      </body>
      <title>Passing a null value to an int in .NET</title>
      <guid isPermaLink="false">http://net.bloggix.com/PermaLink,guid,ef822f4b-0f70-4cb9-afb7-e2e5099e01e1.aspx</guid>
      <link>http://net.bloggix.com/2005/05/17/PassingANullValueToAnIntInNET.aspx</link>
      <pubDate>Tue, 17 May 2005 09:42:58 GMT</pubDate>
      <description>&lt;p&gt;
&lt;font color=#000000&gt;Passing a null value to an int is not possible. The int type is
mapped to the System.Int32 structure type and is not capable of storing a null value.
Only integer values can be stored in there.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;There are two ways which i know of how to solve this problem.
The first method is using an object in stead of the int type. For example:&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;object val = 200;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;if (val != null)&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;return (int)val;&lt;br&gt;
}&lt;br&gt;
&lt;/font&gt;
&lt;br&gt;
&lt;font color=#000000&gt;In this way you can set the &lt;font face="Courier New" color=#808080&gt;val&lt;/font&gt; variable
to a null value or an integer value. In case of an integer value you unbox the value
to retrieve the integer value.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;A second method is using the &lt;font face="Courier New" color=#808080&gt;SqlInt32&lt;/font&gt; type
found in namespace&amp;nbsp;&lt;font face="Courier New" color=#808080&gt;System.Data.SqlTypes&lt;/font&gt; which
is a SQL type. This type supports nullable values. For example:&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#808080&gt;&lt;font face="Courier New"&gt;SqlInt32 val = SqlInt32.Null;&lt;/font&gt; &lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;or&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;SqlInt32 val = 200;&lt;/font&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=ef822f4b-0f70-4cb9-afb7-e2e5099e01e1" /&gt;</description>
      <comments>http://net.bloggix.com/CommentView,guid,ef822f4b-0f70-4cb9-afb7-e2e5099e01e1.aspx</comments>
      <category>C#</category>
      <category>SQL Server</category>
    </item>
    <item>
      <trackback:ping>http://net.bloggix.com/Trackback.aspx?guid=3c634f7f-bae7-4db8-a59f-567e94486505</trackback:ping>
      <pingback:server>http://net.bloggix.com/pingback.aspx</pingback:server>
      <pingback:target>http://net.bloggix.com/PermaLink,guid,3c634f7f-bae7-4db8-a59f-567e94486505.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://net.bloggix.com/CommentView,guid,3c634f7f-bae7-4db8-a59f-567e94486505.aspx</wfw:comment>
      <wfw:commentRss>http://net.bloggix.com/SyndicationService.asmx/GetEntryCommentsRss?guid=3c634f7f-bae7-4db8-a59f-567e94486505</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
This is a very simple example how to transform a Webform.aspx file to a wizard. It
contains two buttons and works even when the back and next button of the browser
are used.
</p>
        <p>
We keep the current page stored in the ViewState. The method ShowPage() should contain
the functionality to show the contents of a wizard page. You could use a PlaceHolder
per wizard page and show/hides these PlaceHolders.
</p>
        <font size="2">
          <p>
          </p>
        </font>
        <font size="1">
          <font color="#0000ff">public</font>
          <font color="#0000ff">class</font> WizardForm:
System.Web.UI.Page<br />
{<br /><font color="#0000ff">protected</font> System.Web.UI.WebControls.Button btnPrev;<br /><font color="#0000ff">protected</font> System.Web.UI.WebControls.Label lblPage;<br /><font color="#0000ff">protected</font> System.Web.UI.WebControls.Button btnNext;<br /><br /><font color="#0000ff">private</font><font color="#0000ff">void</font> Page_Load(<font color="#0000ff">object</font> sender,
System.EventArgs e)<br />
{<br /><font color="#0000ff">   if</font> (!Page.IsPostBack)<br />
   {<br />
      CurrentPage = 0;<br />
   }</font>
        <p>
          <font size="1">   ShowPage();<br />
}</font>
        </p>
        <p>
          <font size="1">
            <font color="#0000ff">private</font>
            <font color="#0000ff">void</font> ShowPage()<br />
{<br />
   lblPage.Text = CurrentPage.ToString();<br />
}</font>
        </p>
        <p>
          <font size="1">
            <font color="#0000ff">private</font>
            <font color="#0000ff">void</font> InitializeComponent()<br />
{ <br />
   <font color="#0000ff">this</font>.btnPrev.Click += <font color="#0000ff">new</font> System.EventHandler(<font color="#0000ff">this</font>.btnPrev_Click);<br />
   <font color="#0000ff">this</font>.btnNext.Click += <font color="#0000ff">new</font> System.EventHandler(<font color="#0000ff">this</font>.btnNext_Click);<br />
   <font color="#0000ff">this</font>.Load += <font color="#0000ff">new</font> System.EventHandler(<font color="#0000ff">this</font>.Page_Load);<br />
}</font>
        </p>
        <p>
          <font size="1">
            <font color="#0000ff">private</font>
            <font color="#0000ff">int</font> CurrentPage<br />
{<br />
   </font>
          <font size="1">
            <font color="#0000ff">get<br /></font>   {<br />
      <font color="#0000ff">object</font> page = ViewState[<font color="#ff0000">"CurrentPage"</font>];</font>
        </p>
        <p>
          <font size="1">
            <font color="#0000ff">      if</font> (page
== <font color="#0000ff">null</font>)<br />
      {<br />
         ViewState[<font color="#ff0000">"CurrentPage"</font>]
= 0;<br />
      }</font>
        </p>
        <p>
          <font size="1">
            <font color="#0000ff">      return</font> Convert.ToInt32(ViewState[<font color="#ff0000">"CurrentPage"</font>]);<br />
   }<br />
   </font>
          <font size="1">
            <font color="#0000ff">set<br />
   </font>{<br />
      ViewState[<font color="#ff0000">"CurrentPage"</font>]
= <font color="#0000ff">value</font>;<br />
   }<br />
}</font>
        </p>
        <p>
          <font size="1">
            <font color="#0000ff">private</font>
            <font color="#0000ff">void</font> btnPrev_Click(<font color="#0000ff">object</font> sender,
System.EventArgs e)<br />
{<br />
   CurrentPage--;<br />
   ShowPage();<br />
}</font>
        </p>
        <p>
          <font size="1">
            <font color="#0000ff">private</font>
            <font color="#0000ff">void</font> btnNext_Click(<font color="#0000ff">object</font> sender,
System.EventArgs e)<br />
{<br />
   CurrentPage++;<br />
   ShowPage();<br />
}<br />
}</font>
        </p>
        <img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=3c634f7f-bae7-4db8-a59f-567e94486505" />
      </body>
      <title>How to: Transform a single Webform.aspx to a wizard</title>
      <guid isPermaLink="false">http://net.bloggix.com/PermaLink,guid,3c634f7f-bae7-4db8-a59f-567e94486505.aspx</guid>
      <link>http://net.bloggix.com/2005/05/12/HowToTransformASingleWebformaspxToAWizard.aspx</link>
      <pubDate>Thu, 12 May 2005 11:53:22 GMT</pubDate>
      <description>&lt;p&gt;
This is a very simple example how to transform a Webform.aspx file to a wizard. It
contains two buttons and&amp;nbsp;works even when the back and next button of the browser
are used.
&lt;/p&gt;
&lt;p&gt;
We keep the current page stored in the ViewState. The method ShowPage() should contain
the functionality to show the contents of a wizard page. You could use a PlaceHolder
per wizard page and show/hides these PlaceHolders.
&lt;/p&gt;
&lt;font size=2&gt; 
&lt;p&gt;
&lt;/font&gt;&lt;font size=1&gt;&lt;font color=#0000ff&gt;public&lt;/font&gt; &lt;font color=#0000ff&gt;class&lt;/font&gt; WizardForm:
System.Web.UI.Page&lt;br&gt;
{&lt;br&gt;
&lt;font color=#0000ff&gt;protected&lt;/font&gt; System.Web.UI.WebControls.Button btnPrev;&lt;br&gt;
&lt;font color=#0000ff&gt;protected&lt;/font&gt; System.Web.UI.WebControls.Label lblPage;&lt;br&gt;
&lt;font color=#0000ff&gt;protected&lt;/font&gt; System.Web.UI.WebControls.Button btnNext;&lt;br&gt;
&lt;br&gt;
&lt;font color=#0000ff&gt;private&lt;/font&gt; &lt;font color=#0000ff&gt;void&lt;/font&gt; Page_Load(&lt;font color=#0000ff&gt;object&lt;/font&gt; sender,
System.EventArgs e)&lt;br&gt;
{&lt;br&gt;
&lt;font color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;if&lt;/font&gt; (!Page.IsPostBack)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CurrentPage = 0;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/font&gt;&gt;
&lt;p&gt;
&lt;font size=1&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;ShowPage();&lt;br&gt;
}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font size=1&gt;&lt;font color=#0000ff&gt;private&lt;/font&gt; &lt;font color=#0000ff&gt;void&lt;/font&gt; ShowPage()&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;lblPage.Text = CurrentPage.ToString();&lt;br&gt;
}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font size=1&gt;&lt;font color=#0000ff&gt;private&lt;/font&gt; &lt;font color=#0000ff&gt;void&lt;/font&gt; InitializeComponent()&lt;br&gt;
{&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color=#0000ff&gt;this&lt;/font&gt;.btnPrev.Click += &lt;font color=#0000ff&gt;new&lt;/font&gt; System.EventHandler(&lt;font color=#0000ff&gt;this&lt;/font&gt;.btnPrev_Click);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color=#0000ff&gt;this&lt;/font&gt;.btnNext.Click += &lt;font color=#0000ff&gt;new&lt;/font&gt; System.EventHandler(&lt;font color=#0000ff&gt;this&lt;/font&gt;.btnNext_Click);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color=#0000ff&gt;this&lt;/font&gt;.Load += &lt;font color=#0000ff&gt;new&lt;/font&gt; System.EventHandler(&lt;font color=#0000ff&gt;this&lt;/font&gt;.Page_Load);&lt;br&gt;
}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font size=1&gt;&lt;font color=#0000ff&gt;private&lt;/font&gt; &lt;font color=#0000ff&gt;int&lt;/font&gt; CurrentPage&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font size=1&gt;&lt;font color=#0000ff&gt;get&lt;br&gt;
&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color=#0000ff&gt;object&lt;/font&gt; page = ViewState[&lt;font color=#ff0000&gt;"CurrentPage"&lt;/font&gt;];&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font size=1&gt;&lt;font color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if&lt;/font&gt; (page
== &lt;font color=#0000ff&gt;null&lt;/font&gt;)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ViewState[&lt;font color=#ff0000&gt;"CurrentPage"&lt;/font&gt;]
= 0;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font size=1&gt;&lt;font color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&lt;/font&gt; Convert.ToInt32(ViewState[&lt;font color=#ff0000&gt;"CurrentPage"&lt;/font&gt;]);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font size=1&gt;&lt;font color=#0000ff&gt;set&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ViewState[&lt;font color=#ff0000&gt;"CurrentPage"&lt;/font&gt;]
= &lt;font color=#0000ff&gt;value&lt;/font&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font size=1&gt;&lt;font color=#0000ff&gt;private&lt;/font&gt; &lt;font color=#0000ff&gt;void&lt;/font&gt; btnPrev_Click(&lt;font color=#0000ff&gt;object&lt;/font&gt; sender,
System.EventArgs e)&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;CurrentPage--;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;ShowPage();&lt;br&gt;
}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font size=1&gt;&lt;font color=#0000ff&gt;private&lt;/font&gt; &lt;font color=#0000ff&gt;void&lt;/font&gt; btnNext_Click(&lt;font color=#0000ff&gt;object&lt;/font&gt; sender,
System.EventArgs e)&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;CurrentPage++;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;ShowPage();&lt;br&gt;
}&lt;br&gt;
}&lt;/font&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=3c634f7f-bae7-4db8-a59f-567e94486505" /&gt;</description>
      <comments>http://net.bloggix.com/CommentView,guid,3c634f7f-bae7-4db8-a59f-567e94486505.aspx</comments>
      <category>ASP.NET</category>
      <category>C#</category>
    </item>
    <item>
      <trackback:ping>http://net.bloggix.com/Trackback.aspx?guid=8dbc776a-6cbb-4383-b5db-686a3ab353d6</trackback:ping>
      <pingback:server>http://net.bloggix.com/pingback.aspx</pingback:server>
      <pingback:target>http://net.bloggix.com/PermaLink,guid,8dbc776a-6cbb-4383-b5db-686a3ab353d6.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://net.bloggix.com/CommentView,guid,8dbc776a-6cbb-4383-b5db-686a3ab353d6.aspx</wfw:comment>
      <wfw:commentRss>http://net.bloggix.com/SyndicationService.asmx/GetEntryCommentsRss?guid=8dbc776a-6cbb-4383-b5db-686a3ab353d6</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <font color="#000000">If you want to use functionality like SPControl.GetContextWeb(Context).Lists
and your trust level is set to WSS_Minimum the code will throw an System.Security.Exception
telling you that:</font>
        </p>
        <p>
          <font face="Courier New" color="#808080">
            <em>Request for the permission of type Microsoft.SharePoint.Security.SharePointPermission,
Microsoft.SharePoint.Security, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c
failed</em>
          </font>
        </p>
        <p>
          <font color="#000000">This means that the code is partial trusted. Normally if
you install your assembly in the GAC it runs with "Full" trust. Microsoft
recommends that you install your web part assemblies in the BIN directory for a more
secure deployment. Therefor the code becomes partial trusted and some functionality
is prohibited by the CAS (Code Access Security) and the trust level set in the
web.config.</font>
        </p>
        <p>
          <font color="#000000">You could set your trust level to "Full" with the risk that
everything is open but that is not a good solution. Maybe in your development environment
but not at the customer. There is another solution! :)</font>
        </p>
        <p>
          <font color="#000000"> Make a copy of the wss_minimaltrust.config file and rename
that file to wss_customtrust.config. The file can be found in the folder:</font>
        </p>
        <p>
          <font size="2">
            <font face="Courier New" color="#808080" size="2">
              <em>&lt;drive&gt;:\Program
Files\Common Files\Microsoft Shared\Web Server Extensions\60\config</em>
            </font>
          </font>
        </p>
        <p>
          <font size="2">
            <font color="#000000" size="2">Make the following changes in this xml
file. These changes will increase the permission level for your web parts.</font>
          </font>
        </p>
        <p>
          <font size="2">
            <font face="Courier New" color="#808080" size="2">&lt;SecurityClasses&gt; <br /></font>
          </font>
          <font size="2">
            <font face="Courier New" color="#808080" size="2">   ...<br /></font>
          </font>
          <font face="Courier New" color="#808080" size="2">   &lt;SecurityClass Name="SharePointPermission" <br />
      Description="Microsoft.SharePoint.Security.SharePointPermission,  <br />
      </font>
          <font size="2">
            <font face="Courier New" color="#808080">Microsoft.SharePoint.Security, <br />
      Version=11.0.0.0, <br />
      </font>
          </font>
          <font size="2">
            <font color="#808080">
              <font face="Courier New">Culture=neutral, <br />
      PublicKeyToken=71e9bce111e9429c"<br />
   /&gt;<br />
&lt;/SecurityClasses&gt;</font>
            </font>
          </font>
        </p>
        <p>
          <font size="2">
            <br />
            <font face="Courier New">
              <font color="#808080">&lt;PermissionSet <font size="2">class</font><font size="2">="NamedPermissionSet" </font><font size="2">version</font><font size="2">="1" </font><font size="2">Name</font></font>
            </font>
            <font face="Courier New">
              <font color="#808080">
                <font size="2">="ASP.Net"&gt;<br /></font>   ...<br /></font>
            </font>
          </font>
          <font size="2">
            <font face="Courier New" color="#808080">   &lt;IPermission class="SharePointPermission" <br />
      version="1" <br />
      ObjectModel="True"<br />
   /&gt;<br />
&lt;/PermissionSet&gt;</font>
          </font>
        </p>
        <p>
          <font color="#000000">In the web.config file of your SharePoint website you will find
a tag called &lt;securityPolicy&gt; and add the following line:</font>
        </p>
        <font size="2">
          <p>
          </p>
        </font>
        <font face="Courier New">
          <font color="#808080">
            <font size="2">&lt;</font>
            <font size="2">trustLevel</font>
            <font size="2">
            </font>
            <font size="2">name</font>
            <font size="2">="WSS_Custom"</font>
            <font size="2">
            </font>
            <font size="2">policyFile</font>
            <font size="2">="&lt;drive&gt;:\Program
Files\Common Files\Microsoft Shared\Web Server Extensions\60\config\wss_customtrust.config"</font>
            <font size="2">
            </font>
            <font size="2">/&gt;</font>
          </font>
        </font>
        <p>
          <font color="#000000">Finally we have to set the trust level in the web.config file
changing the xml to</font>
        </p>
        <font size="2">
          <p>
            <font face="Courier New" color="#808080">&lt;</font>
          </p>
        </font>
        <font face="Courier New">
          <font color="#808080">
            <font size="2">trust</font>
            <font size="2">
            </font>
            <font size="2">level</font>
            <font size="2">="WSS_Custom"</font>
            <font size="2">
            </font>
            <font size="2">originUrl</font>
            <font size="2">=""</font>
            <font size="2">
            </font>
            <font size="2">/&gt;
</font>
          </font>
        </font>
        <p>
          <font color="#000000">More information about WSS Code Access Security can be found
at Microsoft by the following link. <font color="#000000">The article describes the
method i explained above and give some extra tips about trust levels, custom policy
files and more.</font></font>
        </p>
        <p>
          <font color="#006400">
            <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odc_SP2003_ta/html/sharepoint_wsscodeaccesssecurity.asp">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odc_SP2003_ta/html/sharepoint_wsscodeaccesssecurity.asp</a>
          </font>
        </p>
        <img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=8dbc776a-6cbb-4383-b5db-686a3ab353d6" />
      </body>
      <title>Use a custom trust level to get around Code Access Security in SharePoint</title>
      <guid isPermaLink="false">http://net.bloggix.com/PermaLink,guid,8dbc776a-6cbb-4383-b5db-686a3ab353d6.aspx</guid>
      <link>http://net.bloggix.com/2005/05/11/UseACustomTrustLevelToGetAroundCodeAccessSecurityInSharePoint.aspx</link>
      <pubDate>Wed, 11 May 2005 14:14:04 GMT</pubDate>
      <description>&lt;p&gt;
&lt;font color=#000000&gt;If you want to use functionality like SPControl.GetContextWeb(Context).Lists
and your trust level is set to WSS_Minimum the code will throw an System.Security.Exception
telling you that:&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;&lt;em&gt;Request for the permission of type Microsoft.SharePoint.Security.SharePointPermission,
Microsoft.SharePoint.Security, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c
failed&lt;/em&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;This means that the code is partial trusted.&amp;nbsp;Normally if
you install&amp;nbsp;your assembly in the&amp;nbsp;GAC&amp;nbsp;it runs with "Full" trust. Microsoft
recommends that you install your web part assemblies in the BIN directory for a more
secure deployment.&amp;nbsp;Therefor the code becomes partial trusted and some functionality
is prohibited by the CAS (Code Access Security)&amp;nbsp;and the trust level set in the
web.config.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;You could set your trust level to "Full" with the risk that everything
is open but that is not a good solution. Maybe in your development&amp;nbsp;environment
but not at the customer. There is another solution! :)&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;&amp;nbsp;Make a copy of the wss_minimaltrust.config file and rename
that file to wss_customtrust.config. The file can be found in the folder:&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font size=2&gt;&lt;font face="Courier New" color=#808080 size=2&gt;&lt;em&gt;&amp;lt;drive&amp;gt;:\Program
Files\Common Files\Microsoft Shared\Web Server Extensions\60\config&lt;/em&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font size=2&gt;&lt;font color=#000000 size=2&gt;Make the following changes in this xml file.
These changes will increase the permission level for your web parts.&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font size=2&gt;&lt;font face="Courier New" color=#808080 size=2&gt;&amp;lt;SecurityClasses&amp;gt;&amp;nbsp;&lt;br&gt;
&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New" color=#808080 size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;...&lt;br&gt;
&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New" color=#808080 size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;SecurityClass&amp;nbsp;Name="SharePointPermission"&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Description="Microsoft.SharePoint.Security.SharePointPermission,&amp;nbsp;&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New" color=#808080&gt;Microsoft.SharePoint.Security,&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Version=11.0.0.0,&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;font color=#808080&gt;&lt;font face="Courier New"&gt;Culture=neutral,&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;PublicKeyToken=71e9bce111e9429c"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;/&amp;gt;&lt;br&gt;
&amp;lt;/SecurityClasses&amp;gt;&lt;/font&gt; &lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font size=2&gt;
&lt;br&gt;
&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&amp;lt;PermissionSet &lt;font size=2&gt;class&lt;/font&gt;&lt;font size=2&gt;="NamedPermissionSet" &lt;/font&gt;&lt;font size=2&gt;version&lt;/font&gt;&lt;font size=2&gt;="1" &lt;/font&gt;&lt;font size=2&gt;Name&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt;="ASP.Net"&amp;gt;&lt;br&gt;
&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;...&lt;br&gt;
&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New" color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;IPermission&amp;nbsp;class="SharePointPermission"&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;version="1"&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ObjectModel="True"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;/&amp;gt;&lt;br&gt;
&amp;lt;/PermissionSet&amp;gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;In the web.config file of your SharePoint website you will find
a tag called &amp;lt;securityPolicy&amp;gt; and add the following line:&lt;/font&gt;
&lt;/p&gt;
&lt;font size=2&gt; 
&lt;p&gt;
&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt;&amp;lt;&lt;/font&gt;&lt;font size=2&gt;trustLevel&lt;/font&gt;&lt;font size=2&gt; &lt;/font&gt;&lt;font size=2&gt;name&lt;/font&gt;&lt;font size=2&gt;="WSS_Custom"&lt;/font&gt;&lt;font size=2&gt; &lt;/font&gt;&lt;font size=2&gt;policyFile&lt;/font&gt;&lt;font size=2&gt;="&amp;lt;drive&amp;gt;:\Program
Files\Common Files\Microsoft Shared\Web Server Extensions\60\config\wss_customtrust.config"&lt;/font&gt;&lt;font size=2&gt; &lt;/font&gt;&lt;font size=2&gt;/&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&gt;
&lt;p&gt;
&lt;font color=#000000&gt;Finally we have to set the trust level in the web.config file
changing the xml to&lt;/font&gt;
&lt;/p&gt;
&lt;font size=2&gt; 
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;&amp;lt;&lt;/font&gt;
&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#808080&gt;&lt;font size=2&gt;trust&lt;/font&gt;&lt;font size=2&gt; &lt;/font&gt;&lt;font size=2&gt;level&lt;/font&gt;&lt;font size=2&gt;="WSS_Custom"&lt;/font&gt;&lt;font size=2&gt; &lt;/font&gt;&lt;font size=2&gt;originUrl&lt;/font&gt;&lt;font size=2&gt;=""&lt;/font&gt;&lt;font size=2&gt; &lt;/font&gt;&lt;font size=2&gt;/&amp;gt;&gt;
&lt;/font&gt;&lt;/font&gt;&lt;/font&gt; 
&lt;p&gt;
&lt;font color=#000000&gt;More information about WSS Code Access Security can be found at
Microsoft by the following link. &lt;font color=#000000&gt;The article describes the method
i explained above and give some extra tips about trust levels, custom policy files
and more.&lt;/font&gt;
&lt;/p&gt;
&gt;&gt; 
&lt;p&gt;
&lt;font color=#006400&gt;&lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odc_SP2003_ta/html/sharepoint_wsscodeaccesssecurity.asp"&gt;http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odc_SP2003_ta/html/sharepoint_wsscodeaccesssecurity.asp&lt;/a&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=8dbc776a-6cbb-4383-b5db-686a3ab353d6" /&gt;</description>
      <comments>http://net.bloggix.com/CommentView,guid,8dbc776a-6cbb-4383-b5db-686a3ab353d6.aspx</comments>
      <category>C#</category>
      <category>SharePoint</category>
    </item>
    <item>
      <trackback:ping>http://net.bloggix.com/Trackback.aspx?guid=217c3019-8df4-4d48-a0d4-33d79c2b87c1</trackback:ping>
      <pingback:server>http://net.bloggix.com/pingback.aspx</pingback:server>
      <pingback:target>http://net.bloggix.com/PermaLink,guid,217c3019-8df4-4d48-a0d4-33d79c2b87c1.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://net.bloggix.com/CommentView,guid,217c3019-8df4-4d48-a0d4-33d79c2b87c1.aspx</wfw:comment>
      <wfw:commentRss>http://net.bloggix.com/SyndicationService.asmx/GetEntryCommentsRss?guid=217c3019-8df4-4d48-a0d4-33d79c2b87c1</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://mindsharpblogs.com/todd/">Todd Bleeker</a> wrote an article in SharePoint
Advisor Magazine about "Secure SharePoint Code Using Credential-less impersonation".
He Describes a very cool method using the App Pool identity to complete tasks where
the authenticated user doesn't have permissions for.
</p>
        <p>
His code example for the RevertToAppPool class is as follow:
</p>
        <p>
          <font face="Courier New" color="#808080">using System.Security.Principal;<br /><br />
namespace Mindsharp.Utilities<br />
{<br />
  public class RevertToAppPool<br />
  {<br />
    private WindowsImpersonationContext ctx = null;<br /><br />
    //Revert to the original application pool security context<br />
    //We only want to do this if we are not already running as the
system<br />
    public void UseAppPoolIdentity()<br />
    {<br />
      try<br />
      {<br />
        if (!WindowsIdentity.GetCurrent().IsSystem)<br />
        {<br />
          ctx = WindowsIdentity.Impersonate(System.IntPtr.Zero);<br />
        }<br />
      }<br />
      catch{}<br />
    }<br /><br />
    //Return to impersonating the authenticated user<br />
    //Anonymous users are impersonated as IUSR_machinename, by
default<br />
    public void ReturnToImpersonatingCurrentUser()<br />
    {<br />
      try<br />
      {<br />
        if(ctx != null)<br />
        {<br />
          ctx.Undo();<br />
        }<br />
      }<br />
      catch{}<br />
    }<br />
  }<br />
}<br /></font>
        </p>
        <p>
The code example for the RenderWebPart is as follow:
</p>
        <p>
          <font face="Courier New" color="#808080">protected override void RenderWebPart(HtmlTextWriter
output) 
<br />
{<br />
  try<br />
  {<br />
    output.Write("before:" + WindowsIdentity.GetCurrent().Name + "&lt;BR&gt;");<br />
    Mindsharp.Utilities.RevertToAppPool reverter =<br />
      new Mindsharp.Utilities.RevertToAppPool();<br /><br />
    reverter.UseAppPoolIdentity();<br />
    output.Write("reverted:" + WindowsIdentity.GetCurrent().Name 
<br />
      + "&lt;BR&gt;");<br /><br />
    reverter.ReturnToImpersonatingCurrentUser();<br />
    output.Write("after:" + WindowsIdentity.GetCurrent().Name + "&lt;BR&gt;");<br /><br />
    EnsureChildControls();<br />
    RenderChildren(output);<br />
  }<br />
  catch(Exception ex)<br />
  {<br />
    output.Write("&lt;H1&gt;" + ex.Message + "&lt;/H1&gt;");<br />
  }<br />
}</font>
        </p>
        <p>
For more information goto the article:
</p>
        <p>
          <a href="http://mindsharpblogs.com/todd/archive/2005/05/03/467.aspx">http://mindsharpblogs.com/todd/archive/2005/05/03/467.aspx</a>
        </p>
        <p>
 
</p>
        <img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=217c3019-8df4-4d48-a0d4-33d79c2b87c1" />
      </body>
      <title>Impersonation in SharePoint web parts</title>
      <guid isPermaLink="false">http://net.bloggix.com/PermaLink,guid,217c3019-8df4-4d48-a0d4-33d79c2b87c1.aspx</guid>
      <link>http://net.bloggix.com/2005/05/10/ImpersonationInSharePointWebParts.aspx</link>
      <pubDate>Tue, 10 May 2005 14:04:31 GMT</pubDate>
      <description>&lt;p&gt;
&lt;a href="http://mindsharpblogs.com/todd/"&gt;Todd Bleeker&lt;/a&gt; wrote an article in SharePoint
Advisor Magazine about "Secure SharePoint Code Using Credential-less impersonation".
He Describes a very cool method using the App Pool identity to complete tasks where
the authenticated user doesn't have permissions for.
&lt;/p&gt;
&lt;p&gt;
His code example for the RevertToAppPool class&amp;nbsp;is as follow:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;using System.Security.Principal;&lt;br&gt;
&lt;br&gt;
namespace Mindsharp.Utilities&lt;br&gt;
{&lt;br&gt;
&amp;nbsp; public class RevertToAppPool&lt;br&gt;
&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; private WindowsImpersonationContext ctx = null;&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; //Revert to the original application pool security context&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; //We only want to do this if we are not already running as the
system&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; public void UseAppPoolIdentity()&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; try&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (!WindowsIdentity.GetCurrent().IsSystem)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ctx = WindowsIdentity.Impersonate(System.IntPtr.Zero);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; catch{}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//Return to impersonating the authenticated user&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//Anonymous users are impersonated as IUSR_machinename, by
default&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public void ReturnToImpersonatingCurrentUser()&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; try&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(ctx != null)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ctx.Undo();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; catch{}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp; }&lt;br&gt;
}&lt;br&gt;
&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
The code example for the RenderWebPart is as follow:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;protected override void RenderWebPart(HtmlTextWriter
output) 
&lt;br&gt;
{&lt;br&gt;
&amp;nbsp; try&lt;br&gt;
&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; output.Write("before:" + WindowsIdentity.GetCurrent().Name + "&amp;lt;BR&amp;gt;");&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; Mindsharp.Utilities.RevertToAppPool reverter =&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; new Mindsharp.Utilities.RevertToAppPool();&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; reverter.UseAppPoolIdentity();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; output.Write("reverted:" + WindowsIdentity.GetCurrent().Name 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; + "&amp;lt;BR&amp;gt;");&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; reverter.ReturnToImpersonatingCurrentUser();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; output.Write("after:" + WindowsIdentity.GetCurrent().Name + "&amp;lt;BR&amp;gt;");&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; EnsureChildControls();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; RenderChildren(output);&lt;br&gt;
&amp;nbsp; }&lt;br&gt;
&amp;nbsp; catch(Exception ex)&lt;br&gt;
&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; output.Write("&amp;lt;H1&amp;gt;" + ex.Message + "&amp;lt;/H1&amp;gt;");&lt;br&gt;
&amp;nbsp; }&lt;br&gt;
}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
For more information goto the article:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://mindsharpblogs.com/todd/archive/2005/05/03/467.aspx"&gt;http://mindsharpblogs.com/todd/archive/2005/05/03/467.aspx&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=217c3019-8df4-4d48-a0d4-33d79c2b87c1" /&gt;</description>
      <comments>http://net.bloggix.com/CommentView,guid,217c3019-8df4-4d48-a0d4-33d79c2b87c1.aspx</comments>
      <category>C#</category>
      <category>SharePoint</category>
    </item>
    <item>
      <trackback:ping>http://net.bloggix.com/Trackback.aspx?guid=ea8cc10b-e263-434c-85f1-a94d95979306</trackback:ping>
      <pingback:server>http://net.bloggix.com/pingback.aspx</pingback:server>
      <pingback:target>http://net.bloggix.com/PermaLink,guid,ea8cc10b-e263-434c-85f1-a94d95979306.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://net.bloggix.com/CommentView,guid,ea8cc10b-e263-434c-85f1-a94d95979306.aspx</wfw:comment>
      <wfw:commentRss>http://net.bloggix.com/SyndicationService.asmx/GetEntryCommentsRss?guid=ea8cc10b-e263-434c-85f1-a94d95979306</wfw:commentRss>
      <slash:comments>8</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <font color="#000000">When you create a property in your WebPart and give it some
extra attributes it will appear as a control when you modify your WebPart. The following
code is an example:</font>
        </p>
        <p>
          <font face="Courier New" color="#808080">[Browsable(true),<br />
Category("Customer"),<br />
DefaultValue(0),<br />
WebPartStorage(Storage.Shared),<br />
FriendlyName("Customer ID"),<br />
Description("Fill in the customer ID")]<br />
public int CustomerID<br />
{<br />
   get<br />
   {<br />
      return customerID;<br />
   }<br />
   set<br />
   {<br />
      customerID = value;<br />
   }<br />
}</font>
        </p>
        <p>
          <font color="#000000">This example creates a category named "Customer" with one field.
the FriendlyName(..) is used as description for the field and the Description(..)
is used as tooltip text. When no value is set the DefaultValue(..) is used as default
value. In this case the field contains a zero.</font>
          <font face="Courier New" color="#808080">
          </font>
        </p>
        <p>
          <img src="http://blogs.tamtam.nl/alexander/content/binary/toolpart2.jpg" border="0" />
        </p>
        <p>
          <font color="#000000">When you use properties you only have a few possibilities. Checkboxes
are used for booleans, Text fields are used for doubles, int, strings, etc and a dropdownlist
is used for enumerations.</font>
        </p>
        <p>
          <font color="#000000">So why not create your own ToolPart with default and/or your
own controls? It is even not that difficult. :)</font>
        </p>
        <p>
          <font color="#000000">I'm working on a BirthdayWebPart which needs some functionality
to select through a dropdown box the contact list. But only enumerations are shown
using a dropdown list. So we have to write our own ToolPart.</font>
        </p>
        <p>
          <font color="#000000">First we create a new class derived from the class Microsoft.SharePoint.WebPartPages.ToolPart.
You could do this by hand or use the wizard in Visual Studio.</font>
        </p>
        <p>
          <font face="Courier New" color="#808080">public BirthDayToolPart : Microsoft.SharePoint.WebPartPages.ToolPart<br />
{<br />
   private DropDownList ddlList = null;<br /><br />
   public BirthDayToolPart()<br />
   {<br />
      ...</font>
          <font face="Courier New" color="#808080">
            <br />
   }</font>
        </p>
        <p>
          <font face="Courier New" color="#808080">   public override void ApplyChanges()<br />
   {   <br />
      ...<br />
   }<br /><br />
   protected override void RenderToolPart(HtmlTextWriter output)<br />
   {<br />
      ...<br />
   }</font>
          <font face="Courier New" color="#808080">     <br />
}</font>
        </p>
        <p>
          <font color="#000000">We will create and initialise the DropDownList in the constructor
of the class. The DropDownList is filled with the list of available ContactLists. </font>
        </p>
        <p>
          <font face="Courier New" color="#808080">public BirthDayToolPart()<br />
{<br />
   ddlList = new DropDownList();<br />
   ddlList.ID = "ddlContactListName";<br /></font>
          <font face="Courier New" color="#808080">   Controls.Add(ddlList);<br /><br />
   SPWeb currentWeb = SPControl.GetContextWeb(Context);<br />
   foreach(SPList list in currentWeb.Lists)<br />
   {<br />
      if (list.BaseTemplate == SPListTemplate.Contacts)<br />
      {<br />
         ddlList.Items.Add(new ListItem(list.Title,
list.Title));   <br />
      }<br />
   }<br />
}<br /><br /><font face="Verdana" color="#000000">Now we have to render the DropDownList to the
client by overloading the RenderToolPart. We first retrieve the selected web part.
Because this ToolPart belongs to the BirthDayWebPart we can cast it to this class.
The property ContactListName of the BirthDayWebPart is used for getting the currently
selected ContactList. The code is as follow:</font></font>
        </p>
        <p>
          <font face="Courier New" color="#808080">protected override void RenderToolPart(HtmlTextWriter
output)<br />
{<br />
   BirthDayWebPart webPart = ParentToolPane.SelectedWebPart as BirthDayWebPart;<br /><br />
   ddlList.SelectedValue = webPart.ContactListName;<br />
   ddlList.RenderControl(output);<br /></font>
          <font face="Courier New" color="#808080">
            <br />
          </font>
          <font face="Courier New" color="#808080">   // render other
controls and/or write html to the client<br />
   ...<br />
}</font>
        </p>
        <p>
          <font face="Courier New">
            <font face="Verdana" color="#000000">Last but certainly not
lease we override the ApplyChanges for storing the data back into the BirthDayWebPart.
Here we set the ContactListName by using the property of the BirthDayWebPart class.</font>
          </font>
        </p>
        <p>
          <font face="Courier New" color="#808080">public override void ApplyChanges()<br />
{<br />
   BirthDayWebPart webPart = ParentToolPane.SelectedWebPart as BirthDayWebPart;</font>
        </p>
        <p>
          <font face="Courier New" color="#808080">   webPart.ContactListName
= Page.Request.Form[ddlList.ClientID];<br /></font>
          <font face="Courier New" color="#808080">
            <br />
   // store content of other controls<br />
   ...<br />
}<br /><br /><font face="Verdana" color="#000000">The next step is telling the BirthDayWebPart
to use the ToolPart. We override the member GetToolParts() in the BirthDayWebPart
as follow:</font></font>
        </p>
        <p>
          <font face="Courier New" color="#808080">
            <font color="#808080">public override ToolPart[]
GetToolParts()<br />
{<br />
   ToolPart[] toolParts = new ToolPart[3];<br /></font>
          </font>
          <font face="Courier New" color="#808080">
            <font color="#808080">
              <br />
   toolParts[0] = new CustomPropertyToolPart();<br />
   toolParts[1] = new WebPartToolPart();<br />
   toolParts[2] = new BirthDayToolPart();<br /><br />
   return toolParts;<br />
}<br /><br /></font>
          </font>
          <font face="Courier New">
            <font face="Verdana" color="#000000">The CustomPropertyToolPart
represents the default ToolPart that is displayed in the tool pane for a web part
that implements one or more custom properties. Like for example a field containing
the number of days to look forward. </font>
          </font>
        </p>
        <p>
          <font face="Courier New">
            <font face="Verdana" color="#000000">The WebPartToolPart
class represents a ToolPart that can be used to show or modify web part base properties.
Like the minimize and title properties.</font>
          </font>
        </p>
        <p>
          <font face="Courier New">
            <font face="Verdana" color="#000000">The third ToolPart is
our own created BirthDayToolPart.</font>
          </font>
          <font face="Courier New">
          </font>
        </p>
        <img src="http://blogs.tamtam.nl/alexander/content/binary/toolpart1.jpg" border="0" />
        <img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=ea8cc10b-e263-434c-85f1-a94d95979306" />
      </body>
      <title>Create your own ToolPart in SharePoint</title>
      <guid isPermaLink="false">http://net.bloggix.com/PermaLink,guid,ea8cc10b-e263-434c-85f1-a94d95979306.aspx</guid>
      <link>http://net.bloggix.com/2005/05/10/CreateYourOwnToolPartInSharePoint.aspx</link>
      <pubDate>Tue, 10 May 2005 09:49:44 GMT</pubDate>
      <description>&lt;p&gt;
&lt;font color=#000000&gt;When you create a property in your WebPart and give it some extra
attributes it will appear as a control when you modify your WebPart. The following
code is an example:&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;[Browsable(true),&lt;br&gt;
Category("Customer"),&lt;br&gt;
DefaultValue(0),&lt;br&gt;
WebPartStorage(Storage.Shared),&lt;br&gt;
FriendlyName("Customer ID"),&lt;br&gt;
Description("Fill in the customer ID")]&lt;br&gt;
public int CustomerID&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;get&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return customerID;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;set&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;customerID = value;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;This example creates a category named "Customer" with one field.
the FriendlyName(..) is used as description for the field and the Description(..)
is used as tooltip text. When no value is set the DefaultValue(..) is used as default
value. In this case the field contains a zero.&lt;/font&gt;&lt;font face="Courier New" color=#808080&gt;
&lt;/p&gt;
&lt;p&gt;
&gt;&lt;img src="http://blogs.tamtam.nl/alexander/content/binary/toolpart2.jpg" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;When you use properties you only have a few possibilities. Checkboxes
are used for booleans, Text fields are used for doubles, int, strings, etc and a dropdownlist
is used for enumerations.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;So why not create your own ToolPart with default and/or your own
controls? It is even not that difficult. :)&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;I'm working on a BirthdayWebPart which needs some functionality
to select through a dropdown box the contact list. But only enumerations are shown
using a dropdown list. So we have to write our own ToolPart.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;First we create a new class derived from the class Microsoft.SharePoint.WebPartPages.ToolPart.
You could do this by hand or use the wizard in Visual Studio.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;public BirthDayToolPart : Microsoft.SharePoint.WebPartPages.ToolPart&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;private DropDownList ddlList = null;&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;public BirthDayToolPart()&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;...&lt;/font&gt;&lt;font face="Courier New" color=#808080&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;public override void ApplyChanges()&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;{&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;protected override void RenderToolPart(HtmlTextWriter output)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/font&gt;&lt;font face="Courier New" color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;
}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;We will create and initialise the DropDownList in the constructor
of the class. The DropDownList is filled with the list of available ContactLists. &lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;public BirthDayToolPart()&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;ddlList = new DropDownList();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;ddlList.ID = "ddlContactListName";&lt;br&gt;
&lt;/font&gt;&lt;font face="Courier New" color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Controls.Add(ddlList);&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;SPWeb currentWeb = SPControl.GetContextWeb(Context);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;foreach(SPList list in currentWeb.Lists)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if (list.BaseTemplate == SPListTemplate.Contacts)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ddlList.Items.Add(new ListItem(list.Title,
list.Title));&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
&lt;font face=Verdana color=#000000&gt;Now we have to render the DropDownList to the client
by overloading the RenderToolPart. We first retrieve the selected web part. Because
this ToolPart belongs to the BirthDayWebPart we can cast it to this class. The property
ContactListName of the BirthDayWebPart is used for getting the currently selected
ContactList. The code is as follow:&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;protected override void RenderToolPart(HtmlTextWriter
output)&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;BirthDayWebPart webPart = ParentToolPane.SelectedWebPart as BirthDayWebPart;&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;ddlList.SelectedValue = webPart.ContactListName;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;ddlList.RenderControl(output);&lt;br&gt;
&lt;/font&gt;&lt;font face="Courier New" color=#808080&gt;
&lt;br&gt;
&lt;/font&gt;&lt;font face="Courier New" color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// render other controls
and/or write html to the client&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;...&lt;br&gt;
}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&lt;font face=Verdana color=#000000&gt;Last but certainly not lease
we override the ApplyChanges for storing the data back into the BirthDayWebPart. Here
we set the ContactListName by using the property of the BirthDayWebPart class.&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;public override void ApplyChanges()&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;BirthDayWebPart webPart = ParentToolPane.SelectedWebPart as BirthDayWebPart;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;webPart.ContactListName =
Page.Request.Form[ddlList.ClientID];&lt;br&gt;
&lt;/font&gt;&lt;font face="Courier New" color=#808080&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;store content of other controls&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;...&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
&lt;font face=Verdana color=#000000&gt;The next step is telling the BirthDayWebPart to use
the ToolPart. We override the member GetToolParts() in the BirthDayWebPart as follow:&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;&lt;font color=#808080&gt;public override ToolPart[]
GetToolParts()&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;ToolPart[] toolParts = new ToolPart[3];&lt;br&gt;
&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New" color=#808080&gt;&lt;font color=#808080&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;toolParts[0] = new CustomPropertyToolPart();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;toolParts[1] = new WebPartToolPart();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;toolParts[2] = new BirthDayToolPart();&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;return toolParts;&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font face=Verdana color=#000000&gt;The CustomPropertyToolPart
represents the default ToolPart that is displayed in the tool pane for a web part
that implements one or more custom properties. Like for example a field containing
the number of days to look forward. &lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&lt;font face=Verdana color=#000000&gt;The WebPartToolPart class
represents a ToolPart that can be used to show or modify web part base properties.
Like the minimize and title properties.&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&lt;font face=Verdana color=#000000&gt;The third ToolPart is our
own created BirthDayToolPart.&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;
&lt;/p&gt;
&gt;&lt;img src="http://blogs.tamtam.nl/alexander/content/binary/toolpart1.jpg" border=0&gt;&lt;img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=ea8cc10b-e263-434c-85f1-a94d95979306" /&gt;</description>
      <comments>http://net.bloggix.com/CommentView,guid,ea8cc10b-e263-434c-85f1-a94d95979306.aspx</comments>
      <category>ASP.NET</category>
      <category>C#</category>
      <category>SharePoint</category>
    </item>
    <item>
      <trackback:ping>http://net.bloggix.com/Trackback.aspx?guid=7c0dc384-ed6c-4280-a698-1ba5a99a58ef</trackback:ping>
      <pingback:server>http://net.bloggix.com/pingback.aspx</pingback:server>
      <pingback:target>http://net.bloggix.com/PermaLink,guid,7c0dc384-ed6c-4280-a698-1ba5a99a58ef.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://net.bloggix.com/CommentView,guid,7c0dc384-ed6c-4280-a698-1ba5a99a58ef.aspx</wfw:comment>
      <wfw:commentRss>http://net.bloggix.com/SyndicationService.asmx/GetEntryCommentsRss?guid=7c0dc384-ed6c-4280-a698-1ba5a99a58ef</wfw:commentRss>
      <slash:comments>4</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I'm always surprised that SharePoint developers do not often use more web part menus
instead of adding ToolParts. The user doesn't have to go into edit mode which makes
it more user-friendly.
</p>
        <p>
This article decribes a method for adding an item to the menu of the web part. The
menu of a web part can be found in the upper right corner.
</p>
        <p>
          <img src="http://blogs.tamtam.nl/alexander/content/binary/MyWebPart.jpg" border="0" />
        </p>
        <p>
In your web part you have to override the following member:
</p>
        <p>
          <font face="Courier New" color="#808080">public class MyWebPart : Microsoft.SharePoint.WebPartPages.WebPart<br />
{</font>
        </p>
        <p>
          <font face="Courier New" color="#808080"> public override void CreateWebPartMenu()<br />
 {<br />
  base.CreateWebPartMenu();</font>
        </p>
        <p>
          <font face="Courier New" color="#808080">  ...<br />
 }<br />
}</font>
        </p>
        <p>
Inside this member you can do almost anything you want. If your web part is derived
from a web part which already contains some menu items and you want to keep those
just call its base member before adding or changing anything to the menu. I will describe
some examples of what is possible with the menus of a web part.
</p>
        <p>
The web part menu is accessible by the member WebPartMenu of the WebPart class. This
member contains again a member called MenuItems which hold all the menu items of the
menu in a MenuItemCollection. Each MenuItem contains again a member MenuItems which
hold its children in a MenuItemCollection, and so on.
</p>
        <p>
          <br />
The class MenuItemCollection has some nifty methods:
</p>
        <p>
          <font face="Courier New" color="#808080">IndexOf(myMenuItem)</font> will return the
index of the MenuItem myMenuItem.
</p>
        <p>
          <font face="Courier New" color="#808080">ItemFromID(myItemID)</font> will return the
MenuItem having the ID myItemID.
</p>
        <p>
There are two members for adding menu items to the collection. The first is adding
the menu item at the end of the collection. This means that the menu item will appear
at the bottom of the menu. The second way is inserting the menu item at a specified
index. This index could be retrieved using the member <font face="Courier New" color="#808080">IndexOf(..)</font></p>
        <p>
It is also possible to replace an existing menu item by another one using the method <font face="Courier New" color="#808080">Replace(existingMenuItem,
myNewMenuItem)</font>.
</p>
        <p>
          <br />
Adding menu items is very easily and there are some different options. It is possible
to add server side or client side events to the menu item. Below some examples:
</p>
        <p>
          <font face="Courier New" color="#808080">MenuItems.Add(new MenuItem("Click me", "ClickMeId",
new EventHandler(OnClickMe));</font>
        </p>
        <p>
          <font face="Courier New" color="#808080">public void OnClickMe(object sender, EventArg
e)<br />
{<br />
...<br />
}</font>
        </p>
        <p>
This will add the menu item with label "Click me" and a server side event handler.
When the menu item is clicked a postback is generated and the event handler is called.
</p>
        <p>
          <img src="http://blogs.tamtam.nl/alexander/content/binary/MyWebPart_1.jpg" border="0" />
        </p>
        <p>
          <img style="WIDTH: 306px; HEIGHT: 79px" height="86" src="http://blogs.tamtam.nl/alexander/content/binary/MyWebPart_2.jpg" width="306" border="0" />
        </p>
        <p>
          <font face="Courier New" color="#808080">MenuItems.Add(new MenuItem("Click me", "javascript:alert('You
clicked me!');", "ClickMeId"));</font>
        </p>
        <p>
This will add the menu item with label "Click me" and a client side event handler.
When the menu item is clicked it will show a client side generated message box.
</p>
        <p>
          <img src="http://blogs.tamtam.nl/alexander/content/binary/MyWebPart_1.jpg" border="0" />
        </p>
        <p>
          <img src="http://blogs.tamtam.nl/alexander/content/binary/MyWebPart_3.jpg" border="0" />
        </p>
        <p>
Also the menu items has some nice features like BeginSection which gets or sets whether
to create or delete a separator line above the menu item. You can show, hide, check,
uncheck, enable or disable menu items. 
</p>
        <p>
When a menu item had children in its MenuItems collection it will automatically appear
as a popup menu item.
</p>
        <img src="http://blogs.tamtam.nl/alexander/content/binary/MyWebPart_4.jpg" border="0" />
        <img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=7c0dc384-ed6c-4280-a698-1ba5a99a58ef" />
      </body>
      <title>How to create web part menus in SharePoint</title>
      <guid isPermaLink="false">http://net.bloggix.com/PermaLink,guid,7c0dc384-ed6c-4280-a698-1ba5a99a58ef.aspx</guid>
      <link>http://net.bloggix.com/2005/05/04/HowToCreateWebPartMenusInSharePoint.aspx</link>
      <pubDate>Wed, 04 May 2005 08:38:45 GMT</pubDate>
      <description>&lt;p&gt;
I'm always surprised that SharePoint developers do not often use more web part menus
instead of adding ToolParts. The user doesn't have to go into edit mode which makes
it more user-friendly.
&lt;/p&gt;
&lt;p&gt;
This article decribes a method for adding an item to the menu of the web part. The
menu of a web part can be found in the upper right corner.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://blogs.tamtam.nl/alexander/content/binary/MyWebPart.jpg" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
In your web part you have to override the following member:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;public class MyWebPart : Microsoft.SharePoint.WebPartPages.WebPart&lt;br&gt;
{&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;&amp;nbsp;public override void CreateWebPartMenu()&lt;br&gt;
&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;base.CreateWebPartMenu();&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;&amp;nbsp;&amp;nbsp;...&lt;br&gt;
&amp;nbsp;}&lt;br&gt;
}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
Inside this member you can do almost anything you want. If your web part is derived
from a web part which already contains some menu items and you want to keep those
just call its base member before adding or changing anything to the menu. I will describe
some examples of what is possible with the menus of a web part.
&lt;/p&gt;
&lt;p&gt;
The web part menu is accessible by the member WebPartMenu of the WebPart class. This
member contains again a member called MenuItems which hold all the menu items of the
menu in a MenuItemCollection. Each MenuItem contains again a member MenuItems which
hold its children in a MenuItemCollection, and so on.
&lt;/p&gt;
&lt;p&gt;
&lt;br&gt;
The class MenuItemCollection has some nifty methods:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;IndexOf(myMenuItem)&lt;/font&gt; will return the
index of the MenuItem myMenuItem.
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;ItemFromID(myItemID)&lt;/font&gt; will return the
MenuItem having the ID myItemID.
&lt;/p&gt;
&lt;p&gt;
There are two members for adding menu items to the collection. The first is adding
the menu item at the end of the collection. This means that the menu item will appear
at the bottom of the menu. The second way is inserting the menu item at a specified
index. This index could be retrieved using the member &lt;font face="Courier New" color=#808080&gt;IndexOf(..)&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
It is also possible to replace an existing menu item by another one using the method &lt;font face="Courier New" color=#808080&gt;Replace(existingMenuItem,
myNewMenuItem)&lt;/font&gt;.
&lt;/p&gt;
&lt;p&gt;
&lt;br&gt;
Adding menu items is very easily and there are some different options. It is possible
to add server side or client side events to the menu item. Below some examples:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;MenuItems.Add(new MenuItem("Click me", "ClickMeId",
new EventHandler(OnClickMe));&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;public void OnClickMe(object sender, EventArg
e)&lt;br&gt;
{&lt;br&gt;
...&lt;br&gt;
}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
This will add the menu item with label "Click me" and a server side event handler.
When the menu item is clicked a postback is generated and the event handler is called.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://blogs.tamtam.nl/alexander/content/binary/MyWebPart_1.jpg" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;img style="WIDTH: 306px; HEIGHT: 79px" height=86 src="http://blogs.tamtam.nl/alexander/content/binary/MyWebPart_2.jpg" width=306 border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;MenuItems.Add(new MenuItem("Click me", "javascript:alert('You
clicked me!');", "ClickMeId"));&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
This will add the menu item with label "Click me" and a client side event handler.
When the menu item is clicked it will show a client side generated message box.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://blogs.tamtam.nl/alexander/content/binary/MyWebPart_1.jpg" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://blogs.tamtam.nl/alexander/content/binary/MyWebPart_3.jpg" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
Also the menu items has some nice features like BeginSection which gets or sets whether
to create or delete a separator line above the menu item. You can show, hide, check,
uncheck, enable or disable menu items. 
&lt;/p&gt;
&lt;p&gt;
When a menu item had children in its MenuItems collection it will automatically appear
as a popup menu item.
&lt;/p&gt;
&lt;img src="http://blogs.tamtam.nl/alexander/content/binary/MyWebPart_4.jpg" border=0&gt;&lt;img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=7c0dc384-ed6c-4280-a698-1ba5a99a58ef" /&gt;</description>
      <comments>http://net.bloggix.com/CommentView,guid,7c0dc384-ed6c-4280-a698-1ba5a99a58ef.aspx</comments>
      <category>C#</category>
      <category>SharePoint</category>
    </item>
    <item>
      <trackback:ping>http://net.bloggix.com/Trackback.aspx?guid=8b2ed09b-a3b4-4b1b-9c39-f9880c4020b1</trackback:ping>
      <pingback:server>http://net.bloggix.com/pingback.aspx</pingback:server>
      <pingback:target>http://net.bloggix.com/PermaLink,guid,8b2ed09b-a3b4-4b1b-9c39-f9880c4020b1.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://net.bloggix.com/CommentView,guid,8b2ed09b-a3b4-4b1b-9c39-f9880c4020b1.aspx</wfw:comment>
      <wfw:commentRss>http://net.bloggix.com/SyndicationService.asmx/GetEntryCommentsRss?guid=8b2ed09b-a3b4-4b1b-9c39-f9880c4020b1</wfw:commentRss>
      <slash:comments>3</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I expect that there are a lot of people who already wrote some knowlegde article
about this. But it never hurts to explain it again. When you use Response.Transmitfile
for transmitting a file to the client it gets the name of the current aspx file. 
</p>
        <p>
So how do you set the default name of the file which is downloaded to the client? It
is actually very easy. The following code downloads a word file "rapport.doc" to
the client:
</p>
        <p>
string pathFileName = @"c:\documents\rapport.doc";<br />
string fileName = System.IO.Path.GetFileName(pathFileName);
</p>
        <p>
Response.ContentType = "application/msword";<br /><em><font color="#0000ff">Response.AddHeader("Content-Disposition", "attachment; filename="
+ fileName);<br /></font></em>Response.TransmitFile(pathFileName);
</p>
        <img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=8b2ed09b-a3b4-4b1b-9c39-f9880c4020b1" />
      </body>
      <title>Set default name of the file which is downloaded to the client using the Response class</title>
      <guid isPermaLink="false">http://net.bloggix.com/PermaLink,guid,8b2ed09b-a3b4-4b1b-9c39-f9880c4020b1.aspx</guid>
      <link>http://net.bloggix.com/2005/04/28/SetDefaultNameOfTheFileWhichIsDownloadedToTheClientUsingTheResponseClass.aspx</link>
      <pubDate>Thu, 28 Apr 2005 14:41:31 GMT</pubDate>
      <description>&lt;p&gt;
I expect that there are a lot of people who&amp;nbsp;already wrote some knowlegde article
about this. But it never hurts to explain it again. When you use Response.Transmitfile
for transmitting a file to the client it gets the name of the current aspx file. 
&lt;/p&gt;
&lt;p&gt;
So how do you set the default name of the file which is downloaded to the client?&amp;nbsp;It
is actually very easy. The following code downloads a word file "rapport.doc"&amp;nbsp;to
the client:
&lt;/p&gt;
&lt;p&gt;
string pathFileName = @"c:\documents\rapport.doc";&lt;br&gt;
string fileName = System.IO.Path.GetFileName(pathFileName);
&lt;/p&gt;
&lt;p&gt;
Response.ContentType = "application/msword";&lt;br&gt;
&lt;em&gt;&lt;font color=#0000ff&gt;Response.AddHeader("Content-Disposition", "attachment; filename="
+ fileName);&lt;br&gt;
&lt;/font&gt;&lt;/em&gt;Response.TransmitFile(pathFileName);
&lt;/p&gt;
&lt;img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=8b2ed09b-a3b4-4b1b-9c39-f9880c4020b1" /&gt;</description>
      <comments>http://net.bloggix.com/CommentView,guid,8b2ed09b-a3b4-4b1b-9c39-f9880c4020b1.aspx</comments>
      <category>ASP.NET</category>
      <category>C#</category>
    </item>
    <item>
      <trackback:ping>http://net.bloggix.com/Trackback.aspx?guid=e6c702d0-8ec5-4227-9388-7add0821dc24</trackback:ping>
      <pingback:server>http://net.bloggix.com/pingback.aspx</pingback:server>
      <pingback:target>http://net.bloggix.com/PermaLink,guid,e6c702d0-8ec5-4227-9388-7add0821dc24.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://net.bloggix.com/CommentView,guid,e6c702d0-8ec5-4227-9388-7add0821dc24.aspx</wfw:comment>
      <wfw:commentRss>http://net.bloggix.com/SyndicationService.asmx/GetEntryCommentsRss?guid=e6c702d0-8ec5-4227-9388-7add0821dc24</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I like to use singletons in my applications, especially when i don't want to
initialise a class all the time when i need it. The idea behind a singleton class
is to get an instance by calling a static member method and not be able to instantiate
the class yourself. In that way there will only be one instance of the class during
the run of the application. This is accomplished by making the constructor protected.
Normally a singleton class is used in a windows application as follow:
</p>
        <p>
class SomeClass<br />
{<br />
   private static SomeClass instance = null;
</p>
        <p>
   protected SomeClass()<br />
   {<br />
   }
</p>
        <p>
   public static SomeClass Instance<br />
   {<br />
      get<br />
      {<br />
         if (instance == null)<br />
         {<br />
            instance =
new SomeClass();<br />
         }
</p>
        <p>
         return instance;<br />
      }<br />
   }<br />
}
</p>
        <p>
When you want to use the same trick in an ASP.NET application it will not work, because
everytime the class is destroyed when the content of your page is rendered to the
client. But even singletons are usefull in ASP.NET applications and there is a solution
by using for example the session state. The following code shows you how:
</p>
        <p>
class SomeClass<br />
{<br />
   protected SomeClass()<br />
   {<br />
   }
</p>
        <p>
   public static SomeClass Instance<br />
   {<br />
      get<br />
      {<br />
         object instance = System.Web.HttpContext.Current.Session["SomeClassInstance"];<br /><br />
         if (instance == null)<br />
         {<br />
            instance =
System.Web.HttpContext.Current.Session["SomeClassInstance"] = new SomeClass();<br />
         }
</p>
        <p>
         return instance as SomeClass;<br />
      }<br />
   }<br />
}
</p>
        <p>
As you can see it just stores the instance in a session state. You could even store
the instance in the application state if there is need for. It could be helpfull for
your ASP.NET application. :)
</p>
        <img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=e6c702d0-8ec5-4227-9388-7add0821dc24" />
      </body>
      <title>Singletons in ASP.NET applications</title>
      <guid isPermaLink="false">http://net.bloggix.com/PermaLink,guid,e6c702d0-8ec5-4227-9388-7add0821dc24.aspx</guid>
      <link>http://net.bloggix.com/2005/04/23/SingletonsInASPNETApplications.aspx</link>
      <pubDate>Sat, 23 Apr 2005 16:20:55 GMT</pubDate>
      <description>&lt;p&gt;
I&amp;nbsp;like to use singletons in my applications, especially when i don't want to
initialise a class all the time when i need it. The idea behind a singleton class
is to get an instance by calling a static member method and not be able to instantiate
the class yourself. In that way there will only be one instance of the class during
the run of the application. This is accomplished by making the constructor protected.
Normally a singleton class is used in a windows application as follow:
&lt;/p&gt;
&lt;p&gt;
class SomeClass&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;private static SomeClass instance = null;
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;protected SomeClass()&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;public static SomeClass Instance&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;get&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if (instance == null)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;instance =
new SomeClass();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return instance;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
}
&lt;/p&gt;
&lt;p&gt;
When you want to use the same trick in an ASP.NET application it will not work, because
everytime the class is destroyed when the content of your page is rendered to the
client. But even singletons are usefull in ASP.NET applications and there is a solution
by using for example the session state. The following code&amp;nbsp;shows you how:
&lt;/p&gt;
&lt;p&gt;
class SomeClass&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;protected SomeClass()&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;public static SomeClass Instance&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;get&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;object instance = System.Web.HttpContext.Current.Session["SomeClassInstance"];&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if (instance == null)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;instance =
System.Web.HttpContext.Current.Session["SomeClassInstance"] = new SomeClass();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return instance as SomeClass;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
}
&lt;/p&gt;
&lt;p&gt;
As you can see it just stores the instance in a session state. You could even store
the instance in the application state if there is need for. It could be helpfull for
your ASP.NET application. :)
&lt;/p&gt;
&lt;img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=e6c702d0-8ec5-4227-9388-7add0821dc24" /&gt;</description>
      <comments>http://net.bloggix.com/CommentView,guid,e6c702d0-8ec5-4227-9388-7add0821dc24.aspx</comments>
      <category>ASP.NET</category>
      <category>C#</category>
    </item>
    <item>
      <trackback:ping>http://net.bloggix.com/Trackback.aspx?guid=37841079-0ea7-45ad-84e5-e822dedcc048</trackback:ping>
      <pingback:server>http://net.bloggix.com/pingback.aspx</pingback:server>
      <pingback:target>http://net.bloggix.com/PermaLink,guid,37841079-0ea7-45ad-84e5-e822dedcc048.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://net.bloggix.com/CommentView,guid,37841079-0ea7-45ad-84e5-e822dedcc048.aspx</wfw:comment>
      <wfw:commentRss>http://net.bloggix.com/SyndicationService.asmx/GetEntryCommentsRss?guid=37841079-0ea7-45ad-84e5-e822dedcc048</wfw:commentRss>
      <title>Overruling CSS styles in SharePoint pages</title>
      <guid isPermaLink="false">http://net.bloggix.com/PermaLink,guid,37841079-0ea7-45ad-84e5-e822dedcc048.aspx</guid>
      <link>http://net.bloggix.com/2005/04/12/OverrulingCSSStylesInSharePointPages.aspx</link>
      <pubDate>Tue, 12 Apr 2005 12:30:00 GMT</pubDate>
      <description>&lt;p&gt;
&lt;/p&gt;
I got a request from the customer to change the background color&amp;nbsp;of a WSS / Portal&amp;nbsp;page
depending on the login rights. This example delivers an example which will do this.
But the same example can be used to override any other style defined in SPS.css and
OWS.css. 
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
The Following control is written using Visual Studio:
&lt;/p&gt;
&lt;font color=#0000ff&gt; 
&lt;p&gt;
&lt;hr&gt;
using
&lt;/font&gt;&lt;font color=#000000&gt; System;&lt;br&gt;
&lt;/font&gt;&lt;font color=#0000ff&gt;using&lt;/font&gt;&lt;font color=#000000&gt; System.Web.UI;&lt;br&gt;
&lt;/font&gt;&lt;font color=#0000ff&gt;using&lt;/font&gt;&lt;font color=#000000&gt; System.Web.UI.WebControls;&lt;br&gt;
&lt;/font&gt;&lt;font color=#0000ff&gt;using&lt;/font&gt;&lt;font color=#000000&gt; System.ComponentModel;&lt;br&gt;
&lt;/font&gt;&lt;font color=#0000ff&gt;using&lt;/font&gt;&lt;font color=#000000&gt; Microsoft.SharePoint.WebControls;&lt;br&gt;
&lt;/font&gt;&lt;font color=#0000ff&gt;using&lt;/font&gt;&lt;font color=#000000&gt; Microsoft.SharePoint;&lt;/font&gt; 
&lt;p&gt;
&lt;/p&gt;
&lt;font color=#0000ff&gt; 
&lt;p&gt;
namespace
&lt;/font&gt;&lt;font color=#000000&gt; Customer.SharePoint.WebParts&lt;br&gt;
&lt;/font&gt;{&lt;br&gt;
&lt;font color=#808080&gt;///&lt;/font&gt;&lt;font color=#008000&gt; &lt;/font&gt;&lt;font color=#808080&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/font&gt;&lt;font color=#808080&gt;///&lt;/font&gt;&lt;font color=#008000&gt; Summary description for
BodyColor.&lt;br&gt;
&lt;/font&gt;&lt;font color=#808080&gt;///&lt;/font&gt;&lt;font color=#008000&gt; &lt;/font&gt;&lt;font color=#808080&gt;&amp;lt;/summary&amp;gt;&gt;
&lt;/font&gt; 
&lt;p&gt;
[DefaultProperty(&lt;font color=#ff0000&gt;"Text"&lt;/font&gt;), 
&lt;br&gt;
ToolboxData(&lt;font color=#ff0000&gt;"&amp;lt;{0}:BodyColor runat=server&amp;gt;&amp;lt;/{0}:BodyColor&amp;gt;"&lt;/font&gt;)]
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#0000ff&gt;public&lt;/font&gt; &lt;font color=#0000ff&gt;class&lt;/font&gt; BodyColor : System.Web.UI.Control&lt;br&gt;
{&lt;br&gt;
&lt;font color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;private&lt;/font&gt; &lt;font color=#0000ff&gt;bool&lt;/font&gt; IsEditable&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&lt;font color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;get&lt;br&gt;
&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;SPWeb web = SPControl.GetContextWeb(Context);&lt;br&gt;
&lt;br&gt;
&lt;font color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if&lt;/font&gt; (web
== &lt;font color=#0000ff&gt;null&lt;/font&gt;)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&lt;font color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&lt;/font&gt; &lt;font color=#0000ff&gt;false&lt;/font&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;SPUser user = web.CurrentUser;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;bool&lt;/font&gt; hasRight
= web.Permissions.DoesUserHavePermissions(SPRights.ManageWeb);
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&lt;/font&gt; hasRight;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;///&lt;/font&gt;&lt;font color=#008000&gt; &lt;/font&gt;&lt;font color=#808080&gt;&amp;lt;summary&amp;gt;&lt;/font&gt;&lt;font color=#008000&gt;&amp;nbsp;&lt;br&gt;
&lt;/font&gt;&lt;font color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;///&lt;/font&gt;&lt;font color=#008000&gt; Render
this control to the output parameter specified.&lt;br&gt;
&lt;/font&gt;&lt;font color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;///&lt;/font&gt;&lt;font color=#008000&gt; &lt;/font&gt;&lt;font color=#808080&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/font&gt;&lt;font color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;///&lt;/font&gt;&lt;font color=#008000&gt; &lt;/font&gt;&lt;font color=#808080&gt;&amp;lt;param
name="output"&amp;gt;&lt;/font&gt;&lt;font color=#008000&gt; The HTML writer to write out to &lt;/font&gt;&lt;font color=#808080&gt;&amp;lt;/param&amp;gt;
&lt;/p&gt;
&gt; 
&lt;p&gt;
&lt;font color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;protected&lt;/font&gt; &lt;font color=#0000ff&gt;override&lt;/font&gt; &lt;font color=#0000ff&gt;void&lt;/font&gt; Render(HtmlTextWriter
output)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&lt;font color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;string&lt;/font&gt; color = IsEditable
? CustomerConfiguration.EditableBackColor : CustomerConfiguration.NonEditableBackColor;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if&lt;/font&gt; (color != &lt;font color=#ff0000&gt;""&lt;/font&gt;)&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;output.WriteLine(&lt;font color=#ff0000&gt;"&amp;lt;style&amp;gt;body{
background:"&lt;/font&gt; + color + &lt;font color=#ff0000&gt;"; }&amp;lt;/style&amp;gt;"&lt;/font&gt;);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;}&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
}&lt;br&gt;
&lt;br&gt;
}&lt;br&gt;
&lt;hr&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
The control checks the rights of the current user and sets the background color to
one of the defined colors in the web.config. Sign the compiled assembly and place
it in the GAC. Perform the following changes in the default.aspx file found under
the specific template for which you want to override styles. 
&lt;/p&gt;
&lt;p&gt;
&lt;font size=1&gt; 
&lt;hr&gt;
&amp;lt;!-- _lcid="1033" _version="11.0.5510" _dal="1" --&amp;gt;&lt;br&gt;
&amp;lt;!-- _LocalBinding --&amp;gt;&lt;br&gt;
&amp;lt;%@ Page language="C#"&amp;nbsp;&amp;nbsp;Inherits="Microsoft.SharePoint.WebPartPages.WebPartPage,Microsoft.SharePoint,Version=11.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c"
%&amp;gt; 
&lt;br&gt;
&amp;lt;%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls"
Assembly="Microsoft.SharePoint, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"
%&amp;gt; 
&lt;br&gt;
&amp;lt;%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint,
Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %&amp;gt; 
&lt;br&gt;
&amp;lt;%@ Import Namespace="Microsoft.SharePoint" %&amp;gt; 
&lt;br&gt;
&amp;lt;%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages"
Assembly="Microsoft.SharePoint, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"
%&amp;gt;&lt;br&gt;
&lt;/font&gt;&lt;font size=2&gt;&lt;strong&gt;&amp;lt;%@ Register TagPrefix="uc1" NameSpace="Customer&lt;/strong&gt;&lt;strong&gt;.SharePoint.WebParts"
Assembly="Customer.SharePoint.WebParts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c97bf533679d2f6e"
%&amp;gt;&lt;br&gt;
&lt;/strong&gt;&lt;/font&gt;&lt;font size=1&gt;
&lt;br&gt;
&amp;lt;html dir="ltr" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office"&amp;gt;&lt;br&gt;
&amp;lt;HEAD&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;META Name="GENERATOR" Content="Microsoft SharePoint"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;META Name="ProgId" Content="SharePoint.WebPartPage.Document"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;META Name="CollaborationServer" Content="SharePoint Team Web
Site"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;META HTTP-EQUIV="Expires" content="0"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Title ID=onetidTitle&amp;gt;Home - &amp;lt;SharePoint:ProjectProperty
Property="Title" runat="server"/&amp;gt;&amp;lt;/Title&amp;gt;&lt;/font&gt; 
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font size=1&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;script src="/_layouts/&amp;lt;%=System.Threading.Thread.CurrentThread.CurrentUICulture.LCID%&amp;gt;/owsbrows.js"&amp;gt;&amp;lt;/script&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;Link REL="stylesheet" Type="text/css" HREF="/_layouts/&amp;lt;%=System.Threading.Thread.CurrentThread.CurrentUICulture.LCID%&amp;gt;/styles/ows.css"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;!--mstheme--&amp;gt;&amp;lt;SharePoint:Theme runat="server"/&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;META Name="Microsoft Theme" Content="default"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;META Name="Microsoft Border" Content="none"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;script&amp;gt;&amp;lt;!--&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (browseris.mac &amp;amp;&amp;amp; !browseris.ie5up)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; var ms_maccssfpfixup = "/_layouts/&amp;lt;%=System.Threading.Thread.CurrentThread.CurrentUICulture.LCID%&amp;gt;/styles/owsmac.css";&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; document.write("&amp;lt;link rel='stylesheet' Type='text/css'
href='" + ms_maccssfpfixup + "'&amp;gt;");&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //--&amp;gt;&amp;lt;/script&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;style&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; v\:*&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; { behavior:
url(#default#VML) }&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; o\:*&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; { behavior:
url(#default#VML) }&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .shape&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; { behavior: url(#default#VML)
}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/style&amp;gt;&lt;br&gt;
&lt;br&gt;
&lt;/font&gt;&lt;font size=2&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;uc1:BodyColor runat="server"
id="bc"&amp;gt;&amp;lt;/uc1:BodyColor&amp;gt;&lt;br&gt;
&lt;/strong&gt;&lt;/font&gt;&lt;font size=1&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;link type="text/xml" rel='alternate' href="_vti_bin/spdisco.aspx"
/&amp;gt;&lt;br&gt;
&amp;lt;/HEAD&amp;gt;&lt;br&gt;
&amp;lt;body marginwidth="0" marginheight="0" scroll="yes"&amp;gt;&lt;br&gt;
...&lt;br&gt;
&amp;lt;/body&amp;gt;&lt;br&gt;
&amp;lt;/html&amp;gt;&lt;br&gt;
&lt;hr&gt;
&lt;/font&gt; 
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font size=1&gt;&lt;font size=2&gt;When the page is requested the control will override the
style by writing a style tag.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;br&gt;
&lt;/p&gt;
&gt; 
&lt;meta content="Microsoft SharePoint" name=GENERATOR&gt;
&lt;meta content=SharePoint.WebPartPage.Document name=ProgId&gt;
&lt;meta content="SharePoint Team Web Site" name=CollaborationServer&gt;
&lt;meta http-equiv=Expires content=0&gt;
&lt;script src="/_layouts/&lt;%=System.Threading.Thread.CurrentThread.CurrentUICulture.LCID%&gt;/owsbrows.js"&gt;&lt;/script&gt;
&lt;link href="/_layouts/&lt;%=System.Threading.Thread.CurrentThread.CurrentUICulture.LCID%&gt;/styles/ows.css" type=text/css rel=stylesheet&gt;
&lt;!--mstheme--&gt;
&lt;meta content=default name="Microsoft Theme"&gt;
&lt;meta content=none name="Microsoft Border"&gt;
&lt;script&gt;&lt;!--
if (browseris.mac &amp;&amp; !browseris.ie5up)
{
    var ms_maccssfpfixup = "/_layouts/&lt;%=System.Threading.Thread.CurrentThread.CurrentUICulture.LCID%&gt;/styles/owsmac.css";
    document.write("&lt;link rel='stylesheet' Type='text/css' href='" + ms_maccssfpfixup + "'&gt;");
}
//--&gt;&lt;/script&gt;
&lt;style&gt;
v\:*         { behavior: url(#default#VML) }
o\:*         { behavior: url(#default#VML) }
.shape       { behavior: url(#default#VML) }
&lt;/style&gt;
&lt;link href="_vti_bin/spdisco.aspx" type=text/xml rel=alternate&gt;
&lt;img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=37841079-0ea7-45ad-84e5-e822dedcc048" /&gt;</description>
      <comments>http://net.bloggix.com/CommentView,guid,37841079-0ea7-45ad-84e5-e822dedcc048.aspx</comments>
      <category>C#</category>
      <category>SharePoint</category>
    </item>
    <item>
      <trackback:ping>http://net.bloggix.com/Trackback.aspx?guid=5911805b-2060-458c-bd07-21fd2e6a8014</trackback:ping>
      <pingback:server>http://net.bloggix.com/pingback.aspx</pingback:server>
      <pingback:target>http://net.bloggix.com/PermaLink,guid,5911805b-2060-458c-bd07-21fd2e6a8014.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://net.bloggix.com/CommentView,guid,5911805b-2060-458c-bd07-21fd2e6a8014.aspx</wfw:comment>
      <wfw:commentRss>http://net.bloggix.com/SyndicationService.asmx/GetEntryCommentsRss?guid=5911805b-2060-458c-bd07-21fd2e6a8014</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I like to write all my code in C# and therefore i sometimes have to rewrite some examples
written in VB.NET. This website is a quick reference guide to highlight some key syntactical
differences between VB.NET and C#. Thanks to Tom Shelton, Fergus Cooney and others.
</p>
        <p>
          <a href="http://www.harding.edu/USER/fmccown/WWW/vbnet_csharp_comparison.html">http://www.harding.edu/USER/fmccown/WWW/vbnet_csharp_comparison.html</a>
        </p>
        <p>
 
</p>
        <img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=5911805b-2060-458c-bd07-21fd2e6a8014" />
      </body>
      <title>VB.NET and C# Comparison</title>
      <guid isPermaLink="false">http://net.bloggix.com/PermaLink,guid,5911805b-2060-458c-bd07-21fd2e6a8014.aspx</guid>
      <link>http://net.bloggix.com/2005/04/05/VBNETAndCComparison.aspx</link>
      <pubDate>Tue, 05 Apr 2005 07:37:04 GMT</pubDate>
      <description>&lt;p&gt;
I like to write all my code in C# and therefore i sometimes have to rewrite some examples
written in VB.NET. This website is a quick reference guide to highlight some key syntactical
differences between VB.NET and C#. Thanks to Tom Shelton, Fergus Cooney and others.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.harding.edu/USER/fmccown/WWW/vbnet_csharp_comparison.html"&gt;http://www.harding.edu/USER/fmccown/WWW/vbnet_csharp_comparison.html&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=5911805b-2060-458c-bd07-21fd2e6a8014" /&gt;</description>
      <comments>http://net.bloggix.com/CommentView,guid,5911805b-2060-458c-bd07-21fd2e6a8014.aspx</comments>
      <category>.NET</category>
      <category>C#</category>
    </item>
  </channel>
</rss>