<?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! - ASP.NET</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=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=3b57436c-e8fb-4048-b0df-4e344913b151</trackback:ping>
      <pingback:server>http://net.bloggix.com/pingback.aspx</pingback:server>
      <pingback:target>http://net.bloggix.com/PermaLink,guid,3b57436c-e8fb-4048-b0df-4e344913b151.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://net.bloggix.com/CommentView,guid,3b57436c-e8fb-4048-b0df-4e344913b151.aspx</wfw:comment>
      <wfw:commentRss>http://net.bloggix.com/SyndicationService.asmx/GetEntryCommentsRss?guid=3b57436c-e8fb-4048-b0df-4e344913b151</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <font color="#000000">
            <a href="http://blog.u2u.info/DottextWeb/patrick/">Patrick Tisseghem</a> was
going to speak about SharePoint site definitions and templates on the TechEd 2005 in
Amsterdam, but his session agenda has changed. He will be speaking about another very
interesting session:</font>
        </p>
        <p>
          <font color="#000000">
            <strong>
              <u>Creating Dynamic Web Sites with ASP.NET 2.0 Web Parts 
<br /></u>
            </strong>
            <em>"Drill down on the new Web Parts infrastructure in ASP.NET 2.0. Learn
how you can use Web Parts to build rich Web sites-</em>
            <em>enabling end users to dynamically
control the layout of pages-and customize the properties of server controls."</em>
          </font>
        </p>
        <p>
          <font color="#000000">We already had a session internally about this subject given
by <a href="http://blogs.tamtam.nl/mart">Mart</a>. I will certainly be there as SharePoint
Geek! :)</font>
        </p>
        <p>
          <a href="http://blog.u2u.info/DottextWeb/patrick/archive/2005/06/09/4311.aspx">
            <font color="#000000">http://blog.u2u.info/DottextWeb/patrick/archive/2005/06/09/4311.aspx</font>
          </a>
        </p>
        <img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=3b57436c-e8fb-4048-b0df-4e344913b151" />
      </body>
      <title>TechEd: Patrick Tisseghem is going to do another session</title>
      <guid isPermaLink="false">http://net.bloggix.com/PermaLink,guid,3b57436c-e8fb-4048-b0df-4e344913b151.aspx</guid>
      <link>http://net.bloggix.com/2005/06/09/TechEdPatrickTisseghemIsGoingToDoAnotherSession.aspx</link>
      <pubDate>Thu, 09 Jun 2005 06:56:33 GMT</pubDate>
      <description>&lt;p&gt;
&lt;font color=#000000&gt;&lt;a href="http://blog.u2u.info/DottextWeb/patrick/"&gt;Patrick Tisseghem&lt;/a&gt; was
going to speak about SharePoint site definitions and templates on the TechEd 2005&amp;nbsp;in
Amsterdam, but his session agenda has changed. He will be speaking about another very
interesting session:&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;&lt;strong&gt;&lt;u&gt;Creating Dynamic Web Sites with ASP.NET 2.0 Web Parts 
&lt;br&gt;
&lt;/u&gt;&lt;/strong&gt;&lt;em&gt;"Drill down on the new Web Parts infrastructure in ASP.NET 2.0. Learn
how you can use Web Parts to build rich Web sites-&lt;/em&gt;&lt;em&gt;enabling end users to dynamically
control the layout of pages-and customize the properties of server controls."&lt;/em&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;We already had a session internally about this subject given by &lt;a href="http://blogs.tamtam.nl/mart"&gt;Mart&lt;/a&gt;.
I will certainly be there as SharePoint Geek! :)&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.u2u.info/DottextWeb/patrick/archive/2005/06/09/4311.aspx"&gt;&lt;font color=#000000&gt;http://blog.u2u.info/DottextWeb/patrick/archive/2005/06/09/4311.aspx&lt;/font&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=3b57436c-e8fb-4048-b0df-4e344913b151" /&gt;</description>
      <comments>http://net.bloggix.com/CommentView,guid,3b57436c-e8fb-4048-b0df-4e344913b151.aspx</comments>
      <category>.NET</category>
      <category>ASP.NET</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=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=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=60332731-32ef-4267-b24f-8c3be48e893b</trackback:ping>
      <pingback:server>http://net.bloggix.com/pingback.aspx</pingback:server>
      <pingback:target>http://net.bloggix.com/PermaLink,guid,60332731-32ef-4267-b24f-8c3be48e893b.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://net.bloggix.com/CommentView,guid,60332731-32ef-4267-b24f-8c3be48e893b.aspx</wfw:comment>
      <wfw:commentRss>http://net.bloggix.com/SyndicationService.asmx/GetEntryCommentsRss?guid=60332731-32ef-4267-b24f-8c3be48e893b</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I found a great article on <a href="http://www.bluedoglimited.com/SharePointThoughts/default.aspx">SharePoint
Thoughts</a> posted by pBoy about adding a custom ASP.NET application into a site
template. It describes in a few steps how to do this. Some knowlegde is needed because you
will be modifying the ONET.XML. Follow the link below for the whole article:
</p>
        <p>
          <a href="http://www.bluedoglimited.com/SharePointThoughts/ViewPost.aspx?ID=167">http://www.bluedoglimited.com/SharePointThoughts/ViewPost.aspx?ID=167</a>
        </p>
        <img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=60332731-32ef-4267-b24f-8c3be48e893b" />
      </body>
      <title>Adding Custom ASP.NET Applications into a Site Template</title>
      <guid isPermaLink="false">http://net.bloggix.com/PermaLink,guid,60332731-32ef-4267-b24f-8c3be48e893b.aspx</guid>
      <link>http://net.bloggix.com/2005/05/10/AddingCustomASPNETApplicationsIntoASiteTemplate.aspx</link>
      <pubDate>Tue, 10 May 2005 06:36:31 GMT</pubDate>
      <description>&lt;p&gt;
I&amp;nbsp;found a great article on &lt;a href="http://www.bluedoglimited.com/SharePointThoughts/default.aspx"&gt;SharePoint
Thoughts&lt;/a&gt; posted by pBoy about adding a custom ASP.NET application into a site
template. It describes in a few steps how to do this. Some knowlegde is needed because&amp;nbsp;you
will be modifying the ONET.XML.&amp;nbsp;Follow the link below for the whole article:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.bluedoglimited.com/SharePointThoughts/ViewPost.aspx?ID=167"&gt;http://www.bluedoglimited.com/SharePointThoughts/ViewPost.aspx?ID=167&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=60332731-32ef-4267-b24f-8c3be48e893b" /&gt;</description>
      <comments>http://net.bloggix.com/CommentView,guid,60332731-32ef-4267-b24f-8c3be48e893b.aspx</comments>
      <category>ASP.NET</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>
  </channel>
</rss>