<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-10978285</id><updated>2011-11-28T00:24:54.215+01:00</updated><category term='Apple hw'/><category term='C#'/><category term='SharePoint Portal Server'/><category term='teched'/><category term='Joke'/><category term='iPhone'/><category term='Apple'/><category term='Database'/><category term='Code Analysis'/><category term='Contractor consulting'/><category term='Blogging'/><category term='.Net'/><title type='text'>Eqa - Coding things</title><subtitle type='html'>Coding things is a blog about the small discoveries i make in everyday development life in my company Eqa.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://codethings.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10978285/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://codethings.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Kaj Bonfils</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_nwFXASfM7G4/SvA7jv27MvI/AAAAAAAAJVs/i8E3nUD2tnI/S220/kboeqa.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>19</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-10978285.post-5971143575358143015</id><published>2011-08-29T18:43:00.004+02:00</published><updated>2011-08-31T17:07:09.311+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Contractor consulting'/><title type='text'>Why are my clients always wasting their money on me?</title><content type='html'>Update 2011/08/31: I've had a lot of response from other freelancers with similar experiences. They suggested a few extra issues which have been added below. Thanks.&lt;br /&gt;-----------------------------&lt;br /&gt;&lt;br /&gt;As a freelancer / contractor, I startup on new projects or new clients every 6 months or so. I usually get the job through an agent after an interview with the client. During the interview, i try to figure out what the project is about and how the project team is organized, but often the interview is half an hour or less which can make it hard to get all the details nailed down.&lt;br /&gt;Before i actually start, i try to prepare as much as possible, by googling the company, looking at past projects if any is avaliable etc.&lt;br /&gt;But recently i concluded that the preparation is mostly waste... Because my clients doesn't make the same effort to prepare for my arrival. I usually meet up to find that a development environment is missing, the team don't know where the latest version of requirements is located etc. I usually spend the first week either waiting for people to get me ready or to find the people who knows the procedures of the company. If only the clients preparred, i could be productive much faster =&amp;gt; make myself worth the money they pay much faster.&lt;br /&gt;&lt;br /&gt;I've made a list of things that should be ready for the contractor (or any other new people on a project - either new employees or existing employess who is transferred to a project.&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Pc. The hardware must be ready. If it takes time to be preparred by internal it, order the machine to be ready a week before the contractor arrives and test it before. That gives time to fix any issues.&lt;/li&gt;&lt;li&gt;Table and chair. Dont start the first day with rearranging people to make space or clear a corner of one of the other consultant desks. A consultant is no different from other employees. Productivity increases in a clean and tidy environment. And make sure the desk is close to the rest of the development team.&lt;/li&gt;&lt;li&gt;Make sure the user account is up and running. Both normal user accounts with e-mail access etc, and special dev accounts if needed.&lt;/li&gt;&lt;li&gt;Make sure remote access is configured and any security tokens are ready&lt;/li&gt;&lt;li&gt;Have a physical access card ready or make an appointment with a photographer if a photo is required on the access card.&lt;/li&gt;&lt;li&gt;Make a list of people related to the project. Ensure name, email and phone number. If pictures are available, include it. There is a lot of new faces to remember on any new project. Even better: send the list by e-mail with vcf cards attached. That makes it easy to transfer the contacts to my personal phone, which i will usually use.&lt;/li&gt;&lt;li&gt;Make sure that every team member has shared his / her calendar.&lt;/li&gt;&lt;li&gt;Have a manual for time registration ready.&lt;/li&gt;&lt;li&gt;E-mail with links to&lt;/li&gt;&lt;ul&gt;&lt;li&gt;Requirements&lt;/li&gt;&lt;li&gt;Architecture and design documentation&lt;/li&gt;&lt;li&gt;Development standards&lt;/li&gt;&lt;li&gt;Decision logs&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;Make sure a few workpackages are ready and assigned and make sure an existing team member is assigned to do pair development the first few days. The pair development makes it much faster to grasp the idea of the design and the toughts behind the code. Its also a good way to make some social&amp;nbsp;engineering&amp;nbsp;with the existing team - which is a huge benefit for both client and contractor.&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;All items above must be fixed sooner or later. A late fix is an expensive fix. If the fix is made early, it can be planned and carried out by a way person way cheaper than a consultant , e.g. a project secretary.&lt;br /&gt;&lt;br /&gt;So please prepare and let me do what you pay me to do.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10978285-5971143575358143015?l=codethings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codethings.blogspot.com/feeds/5971143575358143015/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10978285&amp;postID=5971143575358143015' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10978285/posts/default/5971143575358143015'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10978285/posts/default/5971143575358143015'/><link rel='alternate' type='text/html' href='http://codethings.blogspot.com/2011/08/why-does-my-clients-always-waste-money.html' title='Why are my clients always wasting their money on me?'/><author><name>Kaj Bonfils</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_nwFXASfM7G4/SvA7jv27MvI/AAAAAAAAJVs/i8E3nUD2tnI/S220/kboeqa.jpg'/></author><thr:total>0</thr:total><georss:featurename>3000 Helsingør, Denmark</georss:featurename><georss:point>56.030787 12.592127000000005</georss:point><georss:box>56.0028325 12.507205000000004 56.0587415 12.677049000000006</georss:box></entry><entry><id>tag:blogger.com,1999:blog-10978285.post-8851615671471419017</id><published>2011-05-15T20:24:00.001+02:00</published><updated>2011-05-15T20:26:48.158+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Apple hw'/><title type='text'>Developer pc</title><content type='html'>Its been two years since my last blog post. I havent died, but even though im still breathing, its been a coupple of busy years. Another kid, a new house etc have taken all my time. But things are looking brighter and im starting to get more tech focused again.&lt;br /&gt;&lt;br /&gt;Thia blog post is about my thoughts on getting some new hw. I think i already decided, but i need some arguments to make sure that the decission i mad with my heart also is the right one for my needs.&lt;br /&gt;&lt;br /&gt;For the last coupple of years, i've been running on mo or less the same hardware. I got a Dell studio XPS 13 a fw year ago. It was equipped with a core 2 dual processor - state of the art at the moment, a decent graphics adapter 4 gigs of mem and 500 gigs of harddrive. It has been upgraded to 8 gb ram to support multiple vm machines and in two steps upggraded, first to a 256 ocz ssd drive and recently to a 600 gb Intel Ssd drive. I even upgraded the battery making the machine run for 5 hrs on a charge. But now it is dying... Its freshly reinstalled and still freezes quite often. It even complains during bios load once in a while. So now its time to look for something new.&lt;br /&gt;&lt;br /&gt;My needs is a state of the art machine for running windows and multiple dev machines on vm ware. I do lots of development in visual studio.&lt;br /&gt;&lt;br /&gt;Im quite into apple gear. I just got my ipad 2 and im loving it. I, of course, have an iPhone and all my digital assets (pics and music) is storred on a mac mini. So my first thought is to get a mac book pro and run windows on it, either natively or using parallels. But wow it is expensive. And it has a few caveats. First, i like to get a 13 inch machine as i do a lot of travelling. But i cant get the 13 inch with a i7 quad core processor, which i would very much like since im doing all my develpment using vm ware machines. The 15" machine would do it, but it is still to bulky and its very expensive.&lt;br /&gt;&lt;br /&gt;My criterias are as follows&lt;br /&gt;Intel core i7 quad processor&lt;br /&gt;8 gb of ram and i will not complain if its possible to upgrade to more.&lt;br /&gt;Hd isn't important as i will move the new 600 gb ssd disk into the new machine anyway.&lt;br /&gt;I prefer a 13 inch because i do lots of commuting (currently 3 hrs pr. day), but a slim 15 inch will do it as well.&lt;br /&gt;I need a a high resolution on the screen as well. My isight is brilliant and i dont mind if my fonts are small as long as there is lots of pixels to use.&lt;br /&gt;I dont care about dvd drive. I dont use it at all.&lt;br /&gt;&lt;br /&gt;Ive been looking around using google, and its really hard to find any matches. I've been Looking at Lenovo machines, but it looks like a german tank. The Sony Vaio might be a match but have no idea of the build quality. Samsung series 9 is good looking but i cant change the hdd to my ssd.&lt;br /&gt;&lt;br /&gt;So what should i do. Pay dkk 20.000 + for an Apple 15 inch of half the price for a new Dell XPS 15 which meets all my requirements except it seems a little bulky? I really dont mind paying the price as this is a tool that is going to be used every day for the next years. So 10k or 20k... Its down to dkk 27 pr day for the most expensive machine... And thats like the first two minutes of payed work every day...shouldn't i just accepting that i work for two minutes to have the tool i really want? &lt;br /&gt;&lt;br /&gt;If i were a carpenter, i wouldn't buy the cheapest nails that bend every time the hammer fall.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;i&gt;Note. This blog post is written on my ipad... I excuse all the typos.&lt;/i&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10978285-8851615671471419017?l=codethings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codethings.blogspot.com/feeds/8851615671471419017/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10978285&amp;postID=8851615671471419017' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10978285/posts/default/8851615671471419017'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10978285/posts/default/8851615671471419017'/><link rel='alternate' type='text/html' href='http://codethings.blogspot.com/2011/05/developer-pc.html' title='Developer pc'/><author><name>Kaj Bonfils</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_nwFXASfM7G4/SvA7jv27MvI/AAAAAAAAJVs/i8E3nUD2tnI/S220/kboeqa.jpg'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10978285.post-9083483924019254686</id><published>2009-05-14T18:45:00.004+02:00</published><updated>2009-05-14T18:51:25.336+02:00</updated><title type='text'>TechEd day 4</title><content type='html'>&lt;a href="http://lh5.ggpht.com/_nwFXASfM7G4/SgxLxA00jOI/AAAAAAAAI70/0FjjeeGV6M8/s1600-h/IMG_1449.JPG"&gt;&lt;img style="MARGIN: 0px 10px 10px 0px; WIDTH: 320px; FLOAT: left; HEIGHT: 240px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5335722963934416098" border="0" alt="Thomas Garp in the HUUGGGEEEE eating all at TechEd" src="http://lh5.ggpht.com/_nwFXASfM7G4/SgxLxA00jOI/AAAAAAAAI70/0FjjeeGV6M8/s320/IMG_1449.JPG" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div&gt;Day 4 on TechEd is going to be spend on the following program:&lt;/div&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Test driven development&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Custom features that enabled users to develop rate and share content with moss 2007. -&lt;/li&gt;&lt;br /&gt;&lt;li&gt;No budget for tools - hot tools on a limited budget&lt;br /&gt;MS silverlight on sharepoint architectural and development patterns&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Design patterns in the real world&lt;/li&gt;&lt;br /&gt;&lt;li&gt;.net on linux and mac&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;p&gt;I dont know if I will be able to take part in all the sessions... I hope to be able to escape for some serious shopping for a coupple of hours as well. And tonight is the Jam Session party, and I should be ready for that as well...&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10978285-9083483924019254686?l=codethings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='related' href='http://www.msteched.com' title='TechEd day 4'/><link rel='replies' type='application/atom+xml' href='http://codethings.blogspot.com/feeds/9083483924019254686/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10978285&amp;postID=9083483924019254686' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10978285/posts/default/9083483924019254686'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10978285/posts/default/9083483924019254686'/><link rel='alternate' type='text/html' href='http://codethings.blogspot.com/2009/05/teched-day-4.html' title='TechEd day 4'/><author><name>Kaj Bonfils</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_nwFXASfM7G4/SvA7jv27MvI/AAAAAAAAJVs/i8E3nUD2tnI/S220/kboeqa.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh5.ggpht.com/_nwFXASfM7G4/SgxLxA00jOI/AAAAAAAAI70/0FjjeeGV6M8/s72-c/IMG_1449.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10978285.post-2959548297028240247</id><published>2009-05-14T18:28:00.003+02:00</published><updated>2009-05-14T18:43:32.369+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='teched'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>TechEd Day 3 followup</title><content type='html'>Day 3 went off with the Zen of Architechture by Juval Lowy... se other post.&lt;br /&gt;&lt;br /&gt;After that breathtaking session, I went for a certification session. The concept is basically that a guy spends 1 hr telling you how to pass a certification test. What is necessary to know, what isn't. I attended a session covering the MS SharePoint 2007 configuration exam. Im pretty confident that I could pass it after reading just a little.&lt;br /&gt;&lt;br /&gt;After lunch, I attended the Applied Entity Framework. But I'm afraid that jetlag and 4 days with only very little sleep kicked in in that session, so I didn't get the benefits I was hoping for. It provided a bit of knowledge in an area that i havent covered in detail before. I think I will try it out, but oher people tell me that I should go for the NHibernate - (When will somebody call it nHyperNate??? It seems to be the new "HYPE" that everything is Hyper :-) )&lt;br /&gt;&lt;br /&gt;I realized that I wasn't able to listnen to more people that day, so I went into solo nerding mode and tried some of the stuff out that i have heard over the last few days. Pretty nice just being me and my friend Visual Studio.&lt;br /&gt;&lt;br /&gt;The day ended in Long Beach with swimming (Not me... I was a woosy) and more mexican food.&lt;br /&gt;&lt;object width="320" height="266" class="BLOG_video_class" id="BLOG_video-7f9f24c2a2488a8c" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"&gt;&lt;param name="movie" value="http://www.youtube.com/get_player"&gt;&lt;param name="bgcolor" value="#FFFFFF"&gt;&lt;param name="allowfullscreen" value="true"&gt;&lt;param name="flashvars" value="flvurl=http://v21.nonxt3.googlevideo.com/videoplayback?id%3D7f9f24c2a2488a8c%26itag%3D5%26app%3Dblogger%26ip%3D0.0.0.0%26ipbits%3D0%26expire%3D1330002448%26sparams%3Did,itag,ip,ipbits,expire%26signature%3D852075D15BD6ABE771A0C13F98C7A9A43EA16E32.6DAFB436F2EF24AA5299E03CE158CCC4EDEE7B73%26key%3Dck1&amp;amp;iurl=http://video.google.com/ThumbnailServer2?app%3Dblogger%26contentid%3D7f9f24c2a2488a8c%26offsetms%3D5000%26itag%3Dw160%26sigh%3DesLQQpgL4vjeKXpXL4PL1ARiZKE&amp;amp;autoplay=0&amp;amp;ps=blogger"&gt;&lt;embed src="http://www.youtube.com/get_player" type="application/x-shockwave-flash"width="320" height="266" bgcolor="#FFFFFF"flashvars="flvurl=http://v21.nonxt3.googlevideo.com/videoplayback?id%3D7f9f24c2a2488a8c%26itag%3D5%26app%3Dblogger%26ip%3D0.0.0.0%26ipbits%3D0%26expire%3D1330002448%26sparams%3Did,itag,ip,ipbits,expire%26signature%3D852075D15BD6ABE771A0C13F98C7A9A43EA16E32.6DAFB436F2EF24AA5299E03CE158CCC4EDEE7B73%26key%3Dck1&amp;iurl=http://video.google.com/ThumbnailServer2?app%3Dblogger%26contentid%3D7f9f24c2a2488a8c%26offsetms%3D5000%26itag%3Dw160%26sigh%3DesLQQpgL4vjeKXpXL4PL1ARiZKE&amp;autoplay=0&amp;ps=blogger"allowFullScreen="true" /&gt;&lt;/object&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10978285-2959548297028240247?l=codethings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='enclosure' type='video/mp4' href='http://www.blogger.com/video-play.mp4?contentId=7f9f24c2a2488a8c&amp;type=video%2Fmp4' length='0'/><link rel='replies' type='application/atom+xml' href='http://codethings.blogspot.com/feeds/2959548297028240247/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10978285&amp;postID=2959548297028240247' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10978285/posts/default/2959548297028240247'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10978285/posts/default/2959548297028240247'/><link rel='alternate' type='text/html' href='http://codethings.blogspot.com/2009/05/teched-day-3-followup.html' title='TechEd Day 3 followup'/><author><name>Kaj Bonfils</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_nwFXASfM7G4/SvA7jv27MvI/AAAAAAAAJVs/i8E3nUD2tnI/S220/kboeqa.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10978285.post-3880679489339570773</id><published>2009-05-13T19:07:00.005+02:00</published><updated>2009-05-13T19:17:10.430+02:00</updated><title type='text'>The Zen of Architecture</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_nwFXASfM7G4/SgsAMofXdpI/AAAAAAAAI7M/kYElgqA95VA/s1600-h/IMG_1445.JPG"&gt;&lt;img style="margin: 0pt 0pt 10px 10px; float: right; cursor: pointer; width: 320px; height: 240px;" src="http://3.bp.blogspot.com/_nwFXASfM7G4/SgsAMofXdpI/AAAAAAAAI7M/kYElgqA95VA/s320/IMG_1445.JPG" alt="" id="BLOGGER_PHOTO_ID_5335358400577894034" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Listened to The Zen of Architecture by Juwal Lowy... He has some very interesting points. Everything can be found in the iDesign.net website. Read and learn.&lt;br /&gt;&lt;br /&gt;I think the principles makes sence,  but it might be a little over engineered for the relatively small projects that im handling. If i implemented his thoughts, I would spend more time doing plumbing of WCF services than on implementing business logic.&lt;br /&gt;&lt;br /&gt;Still, one has to take the parts of his stuff that makes sence.&lt;br /&gt;&lt;br /&gt;Now i'm up for a session about certification - 70-630 Configuring SharePoint 2007.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10978285-3880679489339570773?l=codethings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codethings.blogspot.com/feeds/3880679489339570773/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10978285&amp;postID=3880679489339570773' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10978285/posts/default/3880679489339570773'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10978285/posts/default/3880679489339570773'/><link rel='alternate' type='text/html' href='http://codethings.blogspot.com/2009/05/zen-of-architecture.html' title='The Zen of Architecture'/><author><name>Kaj Bonfils</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_nwFXASfM7G4/SvA7jv27MvI/AAAAAAAAJVs/i8E3nUD2tnI/S220/kboeqa.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_nwFXASfM7G4/SgsAMofXdpI/AAAAAAAAI7M/kYElgqA95VA/s72-c/IMG_1445.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10978285.post-5818298792454206139</id><published>2009-05-13T17:18:00.003+02:00</published><updated>2009-05-13T19:16:15.894+02:00</updated><title type='text'>TechEd 2009 Day 3</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_nwFXASfM7G4/SgsAWgGIdjI/AAAAAAAAI7U/Nd_mXWG3RNU/s1600-h/IMG_1446.JPG"&gt;&lt;img style="margin: 0pt 0pt 10px 10px; float: right; cursor: pointer; width: 320px; height: 240px;" src="http://4.bp.blogspot.com/_nwFXASfM7G4/SgsAWgGIdjI/AAAAAAAAI7U/Nd_mXWG3RNU/s320/IMG_1446.JPG" alt="" id="BLOGGER_PHOTO_ID_5335358570123261490" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;I didn't make it to the blog yesterday, but I will try to put a little info on later about the stuff that happened.&lt;br /&gt;&lt;br /&gt;Today is going to be an exiting day. There is so many sessions I would like to follow but too little time:&lt;br /&gt;&lt;br /&gt;Slot 1:&lt;br /&gt;Zen of architecture - with Juwal Lowy... Im going to this one.&lt;br /&gt;Understanding virtualization and MOSS 2007&lt;br /&gt;&lt;br /&gt;Slot 2:&lt;br /&gt;Preparation for MOSS configuration exam&lt;br /&gt;&lt;br /&gt;Slot 3:&lt;br /&gt;Applied Entity Framework - I think i will take this one&lt;br /&gt;Expploring proper MOSS 2007 Installation and topologies&lt;br /&gt;&lt;br /&gt;Slot 4;&lt;br /&gt;Essential Linq with C# - Probably to intermediate&lt;br /&gt;Practical web testing&lt;br /&gt;SharePoint search challenges and tricks&lt;br /&gt;Building scalable and availabvle web apps with MS Code name Velocity&lt;br /&gt;Expression Blend from a Dev's point of view&lt;br /&gt;How to protect Sharepoint with SCDPM 2007 sp1&lt;br /&gt;&lt;br /&gt;Slot 5:&lt;br /&gt;ADO Entity Framework - Tips and tricks&lt;br /&gt;Version and upgrade of sharepoint solutions&lt;br /&gt;Sharepoinbt online features functionality and customization..&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;And a lot of other interesting stuff.&lt;br /&gt;&lt;br /&gt;Over and out.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10978285-5818298792454206139?l=codethings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codethings.blogspot.com/feeds/5818298792454206139/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10978285&amp;postID=5818298792454206139' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10978285/posts/default/5818298792454206139'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10978285/posts/default/5818298792454206139'/><link rel='alternate' type='text/html' href='http://codethings.blogspot.com/2009/05/teched-2009-day-3.html' title='TechEd 2009 Day 3'/><author><name>Kaj Bonfils</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_nwFXASfM7G4/SvA7jv27MvI/AAAAAAAAJVs/i8E3nUD2tnI/S220/kboeqa.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_nwFXASfM7G4/SgsAWgGIdjI/AAAAAAAAI7U/Nd_mXWG3RNU/s72-c/IMG_1446.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10978285.post-4366636252984226758</id><published>2009-05-11T23:25:00.012+02:00</published><updated>2009-05-12T00:09:55.932+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='teched'/><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint Portal Server'/><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><title type='text'>First day at Tech Ed 2009</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_nwFXASfM7G4/SgiceNpDHbI/AAAAAAAAI1I/uVUsMPyN_Kg/s1600-h/Los+Angeles+2009+083.JPG"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 320px; height: 240px;" src="http://2.bp.blogspot.com/_nwFXASfM7G4/SgiceNpDHbI/AAAAAAAAI1I/uVUsMPyN_Kg/s320/Los+Angeles+2009+083.JPG" alt="" id="BLOGGER_PHOTO_ID_5334685801492192690" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;The TechEd conference of 2009 is kicked off. I am attending with two colleagues from &lt;a href="http://www.d60.dk/"&gt;D60&lt;/a&gt;, Thomas Garp and Henrik Drachman.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;The stored procedure panel&lt;/span&gt;&lt;br /&gt;&lt;a href="http://jeffreypalermo.com/blog/stored-procedure-panel-at-teched-2009/"&gt;&lt;/a&gt;&lt;br /&gt;I really had high expectations to this one. Finally we were going to end the battle between the T-SQL and SP guys. The panel discussed the various problems with both methods of SQL access, including performance, security and application architecture. The conclusion was, that there is no conclusion. The stored procedures are better in ways of security, performance (Both by using compiled execution plans and by lowering the actual network trafic) and gives a better application architecture by separating the datalayer completely. On the other hand, using T-SQL provides a flexibility that cant be provided by SP's. A final comment was, that SP's should be used unless there is compelling reasons not to do so... I think I can agree on that one.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Keynote&lt;/span&gt;&lt;br /&gt;This years keynote speaker was Bill Veghte,  who spoke about Win 7, Windows Server 2008r2 and other stuff. The keynote provided a few interesting point but it was largely a waste of time. The highlight was the announcement of shipdates for win 7 and W2k8r2 before christmas.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;A lap around MS Asp.Net 4.0 and Visual Studio 2010&lt;/span&gt;&lt;br /&gt;This session covered some of the new functionality in VS 2008. Especially snippets for HTML and improvement of the way ASP.Net markup is written was demonstrated. This will give a significant lift to the way HTML and markup is written.&lt;br /&gt;There was a lot of demos of Ajax, Data access etc, but nothing really interesting. The best announcement was the introduction of the ability to have a debug and production web.config file in a project. ABOUT F...ING TIME!&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Developing SharePoint solutions with the VSeWss3.0 1.3&lt;br /&gt;&lt;/span&gt;Version 1.3 of the VSeWSS 1.3 is in a CTP and soon available. In VS 2010 these tools will be build into the development environment.&lt;br /&gt;&lt;br /&gt;In version 1.3 there is a number of changes: A number of deployment settings have been added, most of the resembling the Carsten Keutmann tool. These tools will probably be the stuff that will make the VSeWSS usable :-)&lt;br /&gt;&lt;br /&gt;There is also functionalty to rename features, moving files etc in the dev. environment.&lt;br /&gt;&lt;br /&gt;Most important is that the VSeWSS now can run on a 64 bit machine. This functionality is very much needed. There still isn't a visual designer, but that should also be part of the Visual Studio 2010.&lt;br /&gt;&lt;br /&gt;Thats it for the commercials in this event... The rest was demos and lots of usable code examples. There wasn't really any earth shaking news, but still good be confirmed in the strategy im using when developing solutions for MOSS-&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10978285-4366636252984226758?l=codethings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codethings.blogspot.com/feeds/4366636252984226758/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10978285&amp;postID=4366636252984226758' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10978285/posts/default/4366636252984226758'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10978285/posts/default/4366636252984226758'/><link rel='alternate' type='text/html' href='http://codethings.blogspot.com/2009/05/first-day-at-tech-ed-2009.html' title='First day at Tech Ed 2009'/><author><name>Kaj Bonfils</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_nwFXASfM7G4/SvA7jv27MvI/AAAAAAAAJVs/i8E3nUD2tnI/S220/kboeqa.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_nwFXASfM7G4/SgiceNpDHbI/AAAAAAAAI1I/uVUsMPyN_Kg/s72-c/Los+Angeles+2009+083.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10978285.post-3993401768101942937</id><published>2009-02-06T07:59:00.002+01:00</published><updated>2009-02-06T08:01:44.041+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Database'/><category scheme='http://www.blogger.com/atom/ns#' term='Joke'/><title type='text'>Nerdy joke.</title><content type='html'>Its early morning and a long day is ahead... I thought this might start me up in a decent way:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;blockquote&gt;A SQL query walks into a bar and sees two tables. He walks up to them and says 'Can I join you?'&lt;/blockquote&gt;&lt;/strong&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10978285-3993401768101942937?l=codethings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codethings.blogspot.com/feeds/3993401768101942937/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10978285&amp;postID=3993401768101942937' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10978285/posts/default/3993401768101942937'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10978285/posts/default/3993401768101942937'/><link rel='alternate' type='text/html' href='http://codethings.blogspot.com/2009/02/nerdy-joke.html' title='Nerdy joke.'/><author><name>Kaj Bonfils</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_nwFXASfM7G4/SvA7jv27MvI/AAAAAAAAJVs/i8E3nUD2tnI/S220/kboeqa.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10978285.post-312841902735992046</id><published>2008-10-14T06:58:00.004+02:00</published><updated>2008-10-22T22:07:13.675+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Blogging'/><title type='text'>Code markup in Tech blogging</title><content type='html'>Anybody who knows a good tool for tech blogging - especially for making code markup?&lt;br /&gt;&lt;br /&gt;Often it is necessary to include a peace of code in this blog, but the result looks awful. The only posible way to make some kind of format is to encapsulate the code in &amp;lt;code&amp;gt; blocks. An alternative way is to use some of the tools avaliable on the net (e.g. http://delphi.fosdal.com/2008/07/source-code-highlighting-in-blogger.html) but that requires a lot of cut/paste.&lt;br /&gt;&lt;br /&gt;I just want a simple windows application that supports rich text and pasting of code. Somebody must have made this!&lt;br /&gt;&lt;br /&gt;Any suggestions?&lt;br /&gt;&lt;br /&gt;-- 2008 10 22 Update --&lt;br /&gt;Today MSDN Magazine, october 2008 arrived in my mailbox. On page 12, in the Toolbox article, several diferent tools for colorcoding source is mentioned. My favorite is this one:&lt;br /&gt;http://www.jtleigh.com/people/colin/software/CopySourceAsHtml/&lt;br /&gt;&lt;br /&gt;Its a plugin to Visual Studio that integrates into the context menu, providing a "Copy as HTML" link.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10978285-312841902735992046?l=codethings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codethings.blogspot.com/feeds/312841902735992046/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10978285&amp;postID=312841902735992046' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10978285/posts/default/312841902735992046'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10978285/posts/default/312841902735992046'/><link rel='alternate' type='text/html' href='http://codethings.blogspot.com/2008/10/code-markup-in-tech-blogging.html' title='Code markup in Tech blogging'/><author><name>Kaj Bonfils</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_nwFXASfM7G4/SvA7jv27MvI/AAAAAAAAJVs/i8E3nUD2tnI/S220/kboeqa.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10978285.post-9040547296105600001</id><published>2008-07-25T08:56:00.004+02:00</published><updated>2008-07-25T09:07:28.827+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='iPhone'/><category scheme='http://www.blogger.com/atom/ns#' term='Apple'/><title type='text'>IPhone 3G power adapters</title><content type='html'>OK!!! WTF is going in Cupertino these days???&lt;br /&gt;&lt;br /&gt;My last phone was a Nokia. Not that I was very happy with Nokia's, but the fact that i had 5 chargers or so made the choice. One for the office, one for the flat, one for the summerhouse, and plenty of chargers for spare... Then I recieved my Nokia and the finnish people had reinvented the plug. So the result was a pretty bad Nokia N73 (The worst phone ever) with &lt;strong&gt;one&lt;/strong&gt; charger!&lt;br /&gt;&lt;br /&gt;So... This phone lasted for one year. It looked like it had been used in Afghanistan or something. It worked like it had been used as a bomb shield in Baghdad. The Apple came by with this fabolous invention called iPhone 3G!!!!  Hurray. I got one. Only a week after the official release.. not that bad after all. Along with the phone is one power adaptor. But that is not a problem, because this is my 7th iPod, so i have plenty of power adaptors in the drawers.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;NOT&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;The first power adaptor, which has been working perfectly with iPod 3g, nano and a Touch was inserted. The iPhone was quite polite when it told me that it wasn't compatible and couldn't charge using the adapter. Ok... strange, but i just try another. So i put the iPhone into my craddle which is connected to the stereo... &lt;br /&gt;&lt;br /&gt;The iPhone was once again very polite.. "Would you like to keep your iPhone in fly mode?" was the question? WHAT ?? Fly mode ?? Why ?? To not disturb my Iron Maiden collection??&lt;br /&gt;&lt;br /&gt;So Apple dudes? Why couldn't the power adapters needed for the iPhone be the same as the ones needed for iPod, iPod touch, iPod nano etc.??? &lt;br /&gt;&lt;br /&gt;Now, after spending dkk 5500 on an iPhone with a useless subscription (Thankts to Telia) i had to spend another dkk 500 on two extra chargers. I will probably have to spend another dkk 300 to buy a car charger. I haven't tried out the one in my car, but i do not have great expectations.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10978285-9040547296105600001?l=codethings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codethings.blogspot.com/feeds/9040547296105600001/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10978285&amp;postID=9040547296105600001' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10978285/posts/default/9040547296105600001'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10978285/posts/default/9040547296105600001'/><link rel='alternate' type='text/html' href='http://codethings.blogspot.com/2008/07/iphone-3g-power-adapters.html' title='IPhone 3G power adapters'/><author><name>Kaj Bonfils</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_nwFXASfM7G4/SvA7jv27MvI/AAAAAAAAJVs/i8E3nUD2tnI/S220/kboeqa.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10978285.post-1391737350186749773</id><published>2008-07-18T09:50:00.005+02:00</published><updated>2008-07-18T10:01:02.397+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint Portal Server'/><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><title type='text'>Language confusion in Moss</title><content type='html'>I had yet another Moss confusion this morning. I have installed an English Moss and then configured the server with a Danish language pack. When i opened up a site directly from my development server, everything was displayed nicely in danish. The top bar greated me with a "Velkommen Kaj" (I guess even US/UK readers can guess what that means in danish :-) ). When i opened up the site directly on my laptop, the greating was in English... &lt;br /&gt;&lt;br /&gt;As my little green StarWars friend would say:&lt;br /&gt;&lt;blockquote&gt;&lt;em&gt;Strange that is.. yeah!&lt;/em&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;This does not only apply to the greating, but also to the Site Actions menu and help collection.&lt;br /&gt;&lt;br /&gt;So the same site is shown with different language settings on two different machines.&lt;br /&gt;&lt;br /&gt;After a little investigation, i found out that my laptop was set to be located in America. (Control Panel --&gt; Regional and language Settings --&gt; Location). This is what caused it to show these things in English. &lt;br /&gt;&lt;br /&gt;Only developers from out of this planet will be able to explain why this is the way Moss is behaving. But it is! So learn it and behave correctly. If only Moss used my computers language setting, I could understand. Even better, it would just use the language setting of the site. &lt;strong&gt;But it does not&lt;/strong&gt;!&lt;br /&gt;&lt;br /&gt;Luckily i hadn't configured my laptop to be located in Uzbekistan!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10978285-1391737350186749773?l=codethings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codethings.blogspot.com/feeds/1391737350186749773/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10978285&amp;postID=1391737350186749773' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10978285/posts/default/1391737350186749773'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10978285/posts/default/1391737350186749773'/><link rel='alternate' type='text/html' href='http://codethings.blogspot.com/2008/07/language-confusion-in-moss.html' title='Language confusion in Moss'/><author><name>Kaj Bonfils</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_nwFXASfM7G4/SvA7jv27MvI/AAAAAAAAJVs/i8E3nUD2tnI/S220/kboeqa.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10978285.post-8536978160311512470</id><published>2008-05-08T13:52:00.004+02:00</published><updated>2008-10-22T22:04:56.091+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><title type='text'>Memoryleak finally found</title><content type='html'>I have had a long time bug in a website, causing memory to leak. I have really tried everything to ensure that all objects were disposed etc. But nothing helped. In the end, I handled it by recycling the process IIS process when the memorylevel was to high. IT IS NOT A GOOD OPTION... But I had spend so much time looking at this, and I couldn't find the cause.&lt;br /&gt;&lt;br /&gt;It is kind of "I couldn't find the forrest because it is covered by trees."...&lt;br /&gt;&lt;br /&gt;But a lesson is to wait some time (In my case a few months :-)) and the look at it again.&lt;br /&gt;&lt;br /&gt;The problem is, that I'm doing a series of image operations to scale down a picture and apply rounded corners. One of the operations is:&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: Courier New; font-size: 10pt; color: black; background: white;"&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;using&lt;/span&gt; (Image img = System.Drawing.Image.FromHbitmap(bmp.GetHbitmap()))&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; stream = HandleImageFile(img, _width, _height);&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;... blablabla... and then some work with the stream.&lt;br /&gt;&lt;br /&gt;The problem is caused by the Bitmap.GetHbitmap() method. I didn't bother to read the documentation when i originally wrote the code... I just looked at intellisence. The problem is that the GetHbitmap returns an IntPtr object, and these objects are not cleaned up by the Garbage Collector (As it is written in the documentation tsk tsk.)&lt;br /&gt;&lt;br /&gt;So the solution is:&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: Courier New; font-size: 10pt; color: black; background: white;"&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;[System.Runtime.InteropServices.&lt;span style="color: #2b91af;"&gt;DllImport&lt;/span&gt;(&lt;span style="color: #a31515;"&gt;&amp;quot;gdi32.dll&amp;quot;&lt;/span&gt;)]&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;static&lt;/span&gt; &lt;span style="color: blue;"&gt;extern&lt;/span&gt; &lt;span style="color: blue;"&gt;bool&lt;/span&gt; DeleteObject(&lt;span style="color: #2b91af;"&gt;IntPtr&lt;/span&gt; hObject);&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;static&lt;/span&gt; &lt;span style="color: blue;"&gt;bool&lt;/span&gt; HandleImage()&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;{&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #2b91af;"&gt;IntPtr&lt;/span&gt; hBitmap = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;IntPtr&lt;/span&gt;();&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;try&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; hBitmap = bmp.GetHbitmap();&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;using&lt;/span&gt; (Image img = System.Drawing.Image.FromHbitmap(hBitmap))&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; stream = HandleImageFile(img, _width, _height);&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;catch&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;throw&lt;/span&gt;;&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;finally&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; DeleteObject(hBitmap);&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;} &lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Check the original docs here:&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/1dz311e4(VS.85).aspx"&gt;http://msdn.microsoft.com/en-us/library/1dz311e4(VS.85).aspx&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10978285-8536978160311512470?l=codethings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codethings.blogspot.com/feeds/8536978160311512470/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10978285&amp;postID=8536978160311512470' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10978285/posts/default/8536978160311512470'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10978285/posts/default/8536978160311512470'/><link rel='alternate' type='text/html' href='http://codethings.blogspot.com/2008/05/memoryleak-finally-found.html' title='Memoryleak finally found'/><author><name>Kaj Bonfils</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_nwFXASfM7G4/SvA7jv27MvI/AAAAAAAAJVs/i8E3nUD2tnI/S220/kboeqa.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10978285.post-8450567801267408322</id><published>2008-04-22T22:22:00.001+02:00</published><updated>2008-04-22T22:26:59.644+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><title type='text'></title><content type='html'>&lt;h1 id="wx-f"&gt; &lt;font id="rff5" face="Arial, sans-serif" size="4"&gt;&lt;b id="w_2-"&gt;Composite Control Event in ASP.NET&lt;/b&gt;&lt;/font&gt;&lt;/h1&gt;&lt;p id="u70." class="western" style="margin-bottom: 0in;" lang="da-DK"&gt;&lt;font id="rff5" face="Arial, sans-serif"&gt;&lt;font style="font-family: Arial;" id="qcpq" size="2"&gt;&lt;font id="fhd7"&gt;&lt;b id="fnix"&gt;This blog describes the different events that are relevant for rendering a composite control. It is very important to use these events correctly if you want the correct results. Even small mistakes in the use of the events can cause problems later on with events etc.&lt;/b&gt;&lt;/font&gt;&lt;/font&gt;&lt;b id="w_2-"&gt;&lt;br id="s:.3"&gt;&lt;/b&gt;&lt;/font&gt;&lt;/p&gt; &lt;br id="c2w2"&gt;&lt;font id="n185" size="2"&gt;&lt;font id="gxk4" face="Arial"&gt;Writing a composite control is something most ASP.NET developers will do at some point. It isn't a simple task if you do not know exactly how to do it. But following these basic rules will make your life much easier - and as a bonus, it will also make the reading of the code much easier for the people who will take over your work if you get hit by a car.&lt;/font&gt;&lt;/font&gt;&lt;br id="y-v6"&gt;&lt;p id="fslk" class="western" style="margin-bottom: 0in;" lang="da-DK"&gt;&lt;br id="x55e"&gt;&lt;/p&gt;&lt;p id="fslk" class="western" style="margin-bottom: 0in;" lang="da-DK"&gt;&lt;font id="qr5x" size="2"&gt;&lt;font id="is4x" face="Arial, sans-serif"&gt;Composite controls must inherit Control and implement&lt;/font&gt;&lt;/font&gt;&lt;font id="nw2g" face="Arial, sans-serif"&gt;&lt;font id="v35e" size="2"&gt; INamingContainer.&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;   &lt;h2 id="wjg_"&gt; &lt;font id="p82h" face="Arial, sans-serif"&gt;&lt;font id="z9:x" size="2"&gt;&lt;b id="b:.i"&gt;Constructor&lt;/b&gt;&lt;/font&gt;&lt;/font&gt;&lt;/h2&gt; &lt;p id="qr3o" class="western" style="margin-bottom: 0in;" lang="da-DK"&gt; &lt;font id="shqk" face="Arial, sans-serif"&gt;&lt;font id="drj-" size="2"&gt;The constructor is no different than usual. Set all values that define how the control is rendered here&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;h2 id="hhxb"&gt; &lt;font id="jddm" face="Arial, sans-serif"&gt;&lt;font id="t:2z" size="2"&gt;&lt;b id="yrcn"&gt;OnInit&lt;/b&gt;&lt;/font&gt;&lt;/font&gt;&lt;/h2&gt; &lt;p id="zfz3" class="western" style="margin-bottom: 0in;" lang="da-DK"&gt;&lt;font id="q3.5" face="Arial, sans-serif"&gt;&lt;font id="oo23" size="2"&gt;Create instances of controls that will be rendered on the page. If the controls has events that need to be captured, its necessary to create the events here. Otherwise the events will not be captured.&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;p id="zfz3" class="western" style="margin-bottom: 0in;" lang="da-DK"&gt;&lt;br id="id:l"&gt;&lt;/p&gt;&lt;p id="zfz3" class="western" style="margin-bottom: 0in;" lang="da-DK"&gt;&lt;font id="q3.5" face="Arial, sans-serif"&gt;&lt;font id="oo23" size="2"&gt;Also this is the place to set the static attributes of the controls.&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;p id="zfz3" class="western" style="margin-bottom: 0in;" lang="da-DK"&gt;&lt;font id="q3.5" face="Arial, sans-serif"&gt;&lt;font id="oo23" size="2"&gt;&lt;br id="l-e2"&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;p id="zfz3" class="western" style="margin-bottom: 0in;" lang="da-DK"&gt;&lt;font id="q3.5" face="Arial, sans-serif"&gt;&lt;font id="oo23" size="2"&gt;Note that the controls are defined as protected attributes on the class and not just as local variables in the OnInit method. Also note that the controls are not added to the class's control collection yet.&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;br id="cfzo"&gt;&lt;p id="ryhs" class="western" style="margin-bottom: 0in;" lang="en-AU"&gt;&lt;br id="m3.x"&gt;&lt;/p&gt;&lt;p id="ryhs" class="western" style="margin-bottom: 0in;" lang="en-AU"&gt;&lt;font id="b9ck" size="2"&gt;&lt;font id="oh59" face="Courier New, monospace"&gt;&lt;font id="ecb0" color="#0000ff"&gt;protected &lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font id="o_w1" size="2"&gt;&lt;font id="jym0" face="Courier New, monospace"&gt;&lt;font id="g82c" color="#008080"&gt;ImageButton&lt;/font&gt; _btnEdit;&lt;/font&gt;&lt;/font&gt; &lt;/p&gt;&lt;p id="ryhs" class="western" style="margin-bottom: 0in;" lang="en-AU"&gt;&lt;font id="b9ck" size="2"&gt;&lt;font id="oh59" face="Courier New, monospace"&gt;&lt;font id="ecb0" color="#0000ff"&gt;&lt;br id="irat"&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;p id="ryhs" class="western" style="margin-bottom: 0in;" lang="en-AU"&gt;&lt;font id="b9ck" size="2"&gt;&lt;font id="oh59" face="Courier New, monospace"&gt;&lt;font id="ecb0" color="#0000ff"&gt;protected&lt;/font&gt; &lt;font id="u4t7" color="#0000ff"&gt;override&lt;/font&gt; &lt;font id="obmf" color="#0000ff"&gt;void&lt;/font&gt; OnInit( &lt;font id="h40w" color="#008080"&gt;EventArgs&lt;/font&gt; e )&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;p id="heck" class="western" style="margin-bottom: 0in;" lang="en-AU"&gt; &lt;font id="r3bn" face="Courier New, monospace"&gt;&lt;font id="rvel" size="2"&gt;{&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;p id="p0pi" class="western" style="margin-bottom: 0in;" lang="en-AU"&gt; &lt;font id="db7g" size="2"&gt;&lt;font id="mjm8" face="Courier New, monospace"&gt; &lt;font id="db-1" color="#0000ff"&gt;base&lt;/font&gt;.OnInit( e );&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;p id="cq2v" class="western" style="margin-bottom: 0in;" lang="en-AU"&gt; &lt;font id="o_w1" size="2"&gt;&lt;font id="jym0" face="Courier New, monospace"&gt; _btnEdit = &lt;font id="mup2" color="#0000ff"&gt;new&lt;/font&gt; &lt;font id="g82c" color="#008080"&gt;ImageButton&lt;/font&gt;();&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;p id="zqje" class="western" style="margin-bottom: 0in;" lang="en-AU"&gt; &lt;font id="mv33" size="2"&gt;&lt;font id="za-q" face="Courier New, monospace"&gt; _btnEdit.ImageUrl = &lt;font id="o.qv" color="#800000"&gt;"/UI/Images/edit.jpg"&lt;/font&gt;;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;p id="dajk" class="western" style="margin-bottom: 0in;" lang="en-AU"&gt; &lt;font id="j7el" face="Courier New, monospace"&gt;&lt;font id="uw9e" size="2"&gt; _btnEdit.Width = 46;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;p id="b1es" class="western" style="margin-bottom: 0in;" lang="en-AU"&gt; &lt;font id="sten" face="Courier New, monospace"&gt;&lt;font id="m7ow" size="2"&gt; _btnEdit.Height = 18;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;p id="r4h-" class="western" style="margin-bottom: 0in;" lang="en-AU"&gt; &lt;font id="iqfp" size="2"&gt;&lt;font id="yirf" face="Courier New, monospace"&gt; _btnEdit.Click += &lt;font id="atk8" color="#0000ff"&gt;new&lt;/font&gt; &lt;font id="qy66" color="#008080"&gt;ImageClickEventHandler&lt;/font&gt;( BtnEdit_Click );&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;p id="zzr2" class="western" style="margin-bottom: 0in;" lang="en-AU"&gt; &lt;font id="cuq3" size="2"&gt;&lt;font id="b16y" face="Courier New, monospace"&gt; _btnEdit.AlternateText = "Edit";&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;p id="h7hi" class="western" style="margin-bottom: 0in;" lang="da-DK"&gt; &lt;font id="f-o6" face="Courier New, monospace"&gt;&lt;font id="foh3" size="2"&gt;....&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;p id="vevc" class="western" style="margin-bottom: 0in;" lang="da-DK"&gt; &lt;font id="t:ej" face="Courier New, monospace"&gt;&lt;font id="n7tp" size="2"&gt;....&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;p id="lztl" class="western" style="margin-bottom: 0in;" lang="da-DK"&gt; &lt;font id="khpp" face="Courier New, monospace"&gt;&lt;font id="wspd" size="2"&gt;}&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p id="jtoo" class="western" style="margin-bottom: 0in;" lang="da-DK"&gt; &lt;br id="oih_"&gt; &lt;/p&gt; &lt;h2 id="qg1."&gt; &lt;font id="cdaf" face="Arial, sans-serif"&gt;&lt;font id="s.r4" size="2"&gt;&lt;b id="qv7c"&gt;CreateChildControls()&lt;/b&gt;&lt;/font&gt;&lt;/font&gt;&lt;/h2&gt; &lt;p id="kfq1" class="western" style="margin-bottom: 0in;" lang="da-DK"&gt;&lt;font id="n7-6" face="Arial, sans-serif"&gt;&lt;font id="bpds" size="2"&gt;The CreateChildControls is used for adding the sub controls to the class control collection. And nothing else happens here. It is tempting to set attributes etc here, but you shouldn't do that. If you want to build the entire output of controls, they all must be added here - and in the right order. But a good rule is to only add the controls that has interaction with the user. Not attributes for the rendering. Add buttons, text boxes, but do not add controls to render line breaks, images etc.&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;p id="kfq1" class="western" style="margin-bottom: 0in;" lang="da-DK"&gt;&lt;font id="n7-6" face="Arial, sans-serif"&gt;&lt;font id="bpds" size="2"&gt;&lt;br id="pwj2"&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;p id="g6st" class="western" style="margin-bottom: 0in;" lang="en-AU"&gt; &lt;font id="osyo" size="2"&gt;&lt;font id="kqo7" face="Courier New, monospace"&gt;&lt;font id="ehjo" color="#0000ff"&gt;protected&lt;/font&gt; &lt;font id="uj:v" color="#0000ff"&gt;override&lt;/font&gt; &lt;font id="keps" color="#0000ff"&gt;void&lt;/font&gt; CreateChildControls( )&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;p id="log3" class="western" style="margin-bottom: 0in;" lang="en-AU"&gt; &lt;font id="vkda" face="Courier New, monospace"&gt;&lt;font id="dt1z" size="2"&gt;{&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;p id="rzqx" class="western" style="margin-bottom: 0in;" lang="en-AU"&gt; &lt;font id="yait" size="2"&gt;&lt;font id="ajl:" face="Courier New, monospace"&gt; &lt;font id="ivt4" color="#0000ff"&gt;base&lt;/font&gt;.CreateChildControls();&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;p id="nvrg" class="western" style="margin-bottom: 0in;" lang="en-AU"&gt; &lt;font id="r5jh" size="2"&gt;&lt;font id="jqt0" face="Courier New, monospace"&gt; &lt;font id="sf8i" color="#0000ff"&gt;this&lt;/font&gt;.Controls.Add( _btnEdit );&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;p id="pnmx" class="western" style="margin-bottom: 0in;" lang="en-AU"&gt; &lt;font id="jgqu" size="2"&gt;&lt;font id="wwuj" face="Courier New, monospace"&gt; &lt;font id="nawt" color="#0000ff"&gt;this&lt;/font&gt;.Controls.Add( _btnSend );&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;p id="crdw" class="western" style="margin-bottom: 0in;" lang="da-DK"&gt; &lt;font id="wrut" face="Courier New, monospace"&gt;&lt;font id="m.l1" size="2"&gt;}&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;p id="jhkx" class="western" style="margin-bottom: 0in;" lang="da-DK"&gt; &lt;br id="yb2:"&gt; &lt;/p&gt; &lt;h2 id="y2kb"&gt; &lt;font id="hwg2" face="Arial, sans-serif"&gt;&lt;font id="t:t4" size="2"&gt;&lt;b id="w0:z"&gt;RenderControl&lt;/b&gt;&lt;/font&gt;&lt;/font&gt;&lt;/h2&gt; &lt;p id="l0oe" class="western" style="margin-bottom: 0in;" lang="da-DK"&gt; &lt;font id="ot8q" face="Arial, sans-serif"&gt;&lt;font id="vc8g" size="2"&gt;If you, like described above, only add controls that interact with the user, you need to override this method to render the control. The method makes it possible to render HTML around the controls you added in the CreateChildControls method. You can decide when to render the child controls. If you implement this in the Render method, the sub controls will be rendered when the base.Render is called. This means that they will be rendered before or after the HTML you would like to render. Using the RenderControl event, you can decide when the controls will be rendered and by that render them in the correct HTML context.&lt;br id="syni"&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;p id="l0oe" class="western" style="margin-bottom: 0in;" lang="da-DK"&gt;&lt;font id="ot8q" face="Arial, sans-serif"&gt;&lt;font id="vc8g" size="2"&gt;&lt;br id="r3qu"&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;p id="rimp" class="western" style="margin-bottom: 0in;" lang="da-DK"&gt; &lt;font id="sji5" face="Arial, sans-serif"&gt;&lt;font id="c35-" size="2"&gt;Always use the writer parameter to generate the HTML, because it implements some logic that will render correct HTML in different browsers.&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;p id="rimp" class="western" style="margin-bottom: 0in;" lang="da-DK"&gt;&lt;font id="sji5" face="Arial, sans-serif"&gt;&lt;font id="c35-" size="2"&gt;&lt;br id="lz2:"&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;p id="s30q" class="western" style="margin-bottom: 0in;" lang="en-AU"&gt; &lt;font id="s3cb" size="2"&gt;&lt;font id="gl1v" face="Courier New, monospace"&gt;&lt;font id="lkx." color="#0000ff"&gt;public&lt;/font&gt; &lt;font id="tmxm" color="#0000ff"&gt;override&lt;/font&gt; &lt;font id="f-n_" color="#0000ff"&gt;void&lt;/font&gt; RenderControl( &lt;font id="pc0t" color="#008080"&gt;HtmlTextWriter&lt;/font&gt; writer )&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;p id="j50x" class="western" style="margin-bottom: 0in;" lang="en-AU"&gt; &lt;font id="q3x_" face="Courier New, monospace"&gt;&lt;font id="rldc" size="2"&gt;{&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;p id="cpp4" class="western" style="margin-bottom: 0in;" lang="en-AU"&gt; &lt;font id="er9r" size="2"&gt;&lt;font id="u7i8" face="Courier New, monospace"&gt; &lt;font id="zy5l" color="#0000ff"&gt;base&lt;/font&gt;.RenderControl( writer );&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;p id="cpp4" class="western" style="margin-bottom: 0in;" lang="en-AU"&gt;&lt;br id="okgk"&gt;&lt;/p&gt;&lt;p id="cpp4" class="western" style="margin-bottom: 0in;" lang="en-AU"&gt;&lt;font id="er9r" size="2"&gt;&lt;font id="u7i8" face="Courier New, monospace"&gt;// Render title html&lt;br id="xfs9"&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;p id="tm54" class="western" style="margin-bottom: 0in;" lang="en-AU"&gt;   &lt;/p&gt; &lt;p id="opra" class="western" style="margin-bottom: 0in;" lang="en-AU"&gt; &lt;font id="x4bi" size="2"&gt;&lt;font id="mz31" face="Courier New, monospace"&gt; writer.RenderBeginTag(&lt;font id="e83l" color="#008080"&gt;HtmlTextWriterTag&lt;/font&gt;.H3);&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;p id="nzb7" class="western" style="margin-bottom: 0in;" lang="en-AU"&gt; &lt;font id="x:om" size="2"&gt;&lt;font id="k_d8" face="Courier New, monospace"&gt; writer.Write(&lt;/font&gt;&lt;/font&gt;&lt;font id="r7wm" size="2"&gt;&lt;font id="z5lg" face="Courier New, monospace"&gt;&lt;font id="yj43" color="#800000"&gt;"Top of buttons"&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font id="x:om" size="2"&gt;&lt;font id="k_d8" face="Courier New, monospace"&gt;);&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;p id="o-hf" class="western" style="margin-bottom: 0in;" lang="en-AU"&gt; &lt;font id="py58" face="Courier New, monospace"&gt;&lt;font id="ztmx" size="2"&gt; writer.RenderEndTag();&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;p id="logi" class="western" style="margin-bottom: 0in;" lang="en-AU"&gt; &lt;font id="i081" face="Courier New, monospace"&gt;&lt;font id="jm6f" size="2"&gt; writer.WriteLine();&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;p id="mx4c" class="western" style="margin-bottom: 0in;" lang="en-AU"&gt; &lt;br id="vltx"&gt; &lt;/p&gt; &lt;p id="sr8o" class="western" style="margin-bottom: 0in;" lang="en-AU"&gt; &lt;font id="xpr3" face="Courier New, monospace"&gt;&lt;font id="e37i" size="2"&gt; _btnEdit.RenderControl( writer );&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;p id="sr8o" class="western" style="margin-bottom: 0in;" lang="en-AU"&gt;&lt;font id="xpr3" face="Courier New, monospace"&gt;&lt;font id="e37i" size="2"&gt;writer.RenderBeginTag(&lt;/font&gt;&lt;/font&gt;&lt;font id="x4bi" size="2"&gt;&lt;font id="mz31" face="Courier New, monospace"&gt;&lt;font id="e83l" color="#008080"&gt;HtmlTextWriterTag&lt;/font&gt;.BR);&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;p id="sr8o" class="western" style="margin-bottom: 0in;" lang="en-AU"&gt;&lt;font id="py58" face="Courier New, monospace"&gt;&lt;font id="ztmx" size="2"&gt; writer.RenderEndTag();&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;p id="f:-i" class="western" style="margin-bottom: 0in;" lang="en-AU"&gt; &lt;font id="cazo" face="Courier New, monospace"&gt;&lt;font id="w-7t" size="2"&gt; _btnSend.RenderControl( writer );&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;p id="f:-i" class="western" style="margin-bottom: 0in;" lang="en-AU"&gt;&lt;br id="tweq"&gt;&lt;/p&gt;&lt;p id="opra" class="western" style="margin-bottom: 0in;" lang="en-AU"&gt; &lt;font id="x4bi" size="2"&gt;&lt;font id="mz31" face="Courier New, monospace"&gt; writer.RenderBeginTag(&lt;font id="e83l" color="#008080"&gt;HtmlTextWriterTag&lt;/font&gt;.H3);&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;p id="nzb7" class="western" style="margin-bottom: 0in;" lang="en-AU"&gt; &lt;font id="x:om" size="2"&gt;&lt;font id="k_d8" face="Courier New, monospace"&gt; writer.Write(&lt;/font&gt;&lt;/font&gt;&lt;font id="r7wm" size="2"&gt;&lt;font id="z5lg" face="Courier New, monospace"&gt;&lt;font id="yj43" color="#800000"&gt;"End of buttons"&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font id="x:om" size="2"&gt;&lt;font id="k_d8" face="Courier New, monospace"&gt;);&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;p id="o-hf" class="western" style="margin-bottom: 0in;" lang="en-AU"&gt; &lt;font id="py58" face="Courier New, monospace"&gt;&lt;font id="ztmx" size="2"&gt; writer.RenderEndTag();&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;p id="p-g2" class="western" style="margin-bottom: 0in;" lang="da-DK"&gt; &lt;font id="ji1r" face="Courier New, monospace"&gt;&lt;font id="mmnu" size="2"&gt;}&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p id="k16c" class="western" style="margin-bottom: 0in;" lang="da-DK"&gt; &lt;br id="bwh7"&gt; &lt;/p&gt; &lt;h2 id="r2b6"&gt; &lt;font id="w1-j" face="Arial, sans-serif"&gt;&lt;font id="rx09" size="2"&gt;&lt;b id="eazc"&gt;Render&lt;/b&gt;&lt;/font&gt;&lt;/font&gt;&lt;/h2&gt;&lt;p id="pnzq" class="western" style="margin-bottom: 0in;" lang="da-DK"&gt; &lt;font id="aqyx" face="Arial, sans-serif"&gt;&lt;font id="n_di" size="2"&gt;The render method should only be used if you do not wish to build the HTML through the RenderControl method. Using the Render method mean that you only generate HTML from the controls you have added to your control collection. Doing that will render the controls in the same order as they were added to the control collection.&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;p id="pnzq" class="western" style="margin-bottom: 0in;" lang="da-DK"&gt;&lt;br id="huek"&gt;&lt;/p&gt;&lt;p id="pnzq" class="western" style="margin-bottom: 0in;" lang="da-DK"&gt;&lt;font id="aqyx" face="Arial, sans-serif"&gt;&lt;font id="n_di" size="2"&gt;It can still be very valuable to implement this method. It can be used to catch exceptions thrown by the rendering of one of the controls in the control collection.&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;br id="m6dq"&gt;&lt;p id="v_8c" class="western" style="margin-bottom: 0in;" lang="en-AU"&gt; &lt;span id="httx" lang="da-DK"&gt;&lt;font id="m5t4" size="2"&gt;&lt;font id="kmxe" face="Courier New, monospace"&gt;&lt;font id="p4:q" color="#0000ff"&gt;protected&lt;/font&gt; &lt;font id="g4.j" color="#0000ff"&gt;override&lt;/font&gt; &lt;font id="o8ou" color="#0000ff"&gt;void&lt;/font&gt; Render( &lt;font id="o-y2" color="#008080"&gt;HtmlTextWriter&lt;/font&gt; writer )&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p id="be1l" class="western" style="margin-bottom: 0in;" lang="en-AU"&gt; &lt;font id="a:p8" face="Courier New, monospace"&gt;&lt;font id="tbzr" size="2"&gt;{&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;p id="q9is" class="western" style="margin-bottom: 0in;" lang="en-AU"&gt; &lt;font id="ekp0" size="2"&gt;&lt;font id="qw3-" face="Courier New, monospace"&gt; &lt;font id="plrb" color="#0000ff"&gt;try&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;p id="l4_k" class="western" style="margin-bottom: 0in;" lang="en-AU"&gt; &lt;font id="sui4" face="Courier New, monospace"&gt;&lt;font id="ar_n" size="2"&gt; {&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;p id="vxe_" class="western" style="margin-bottom: 0in;" lang="en-AU"&gt; &lt;font id="ajsa" size="2"&gt;&lt;font id="es6_" face="Courier New, monospace"&gt;  &lt;font id="f-bg" color="#0000ff"&gt;base&lt;/font&gt;.Render( writer );&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;p id="k:tu" class="western" style="margin-bottom: 0in;" lang="en-AU"&gt; &lt;font id="qxa1" face="Courier New, monospace"&gt;&lt;font id="awwk" size="2"&gt; }&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;p id="i49b" class="western" style="margin-bottom: 0in;" lang="en-AU"&gt; &lt;font id="tdu8" size="2"&gt;&lt;font id="ei15" face="Courier New, monospace"&gt; &lt;font id="s-eq" color="#0000ff"&gt;catch&lt;/font&gt; ( &lt;font id="y.73" color="#008080"&gt;Exception&lt;/font&gt; ex )&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;p id="cpcp" class="western" style="margin-bottom: 0in;" lang="en-AU"&gt; &lt;font id="wp45" face="Courier New, monospace"&gt;&lt;font id="h9k9" size="2"&gt; {&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;p id="hk8k" class="western" style="margin-bottom: 0in;" lang="en-AU"&gt; &lt;font id="dhs:" size="2"&gt;&lt;font id="s8d2" face="Courier New, monospace"&gt;  &lt;font id="mus6" color="#0000ff"&gt;string&lt;/font&gt; message = &lt;font id="a_bc" color="#800000"&gt;"Error while rendering a control"&lt;/font&gt;;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;font id="wo5r" size="2"&gt;&lt;font id="iw63" face="Courier New, monospace"&gt;//Do logging etc.&lt;br id="j31r"&gt;&lt;br id="wzv3"&gt;&lt;/font&gt;&lt;/font&gt;&lt;p id="i47j" class="western" style="margin-bottom: 0in;" lang="da-DK"&gt;&lt;font id="vx3_" face="Courier New, monospace"&gt;&lt;font id="pir9" size="2"&gt;}&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;p id="orw8" class="western" style="margin-bottom: 0in;" lang="da-DK"&gt; &lt;font id="p2zl" face="Courier New, monospace"&gt;&lt;font id="lcyk" size="2"&gt;}&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;p id="xn2_" class="western" style="margin-bottom: 0in;" lang="da-DK"&gt; &lt;br id="l1v_"&gt; &lt;/p&gt; &lt;h2 id="g12:"&gt; &lt;font id="d-zb" size="2"&gt;&lt;font id="gv9d" face="Arial, sans-serif"&gt;&lt;b id="fdex"&gt;Other&lt;/b&gt;&lt;/font&gt;&lt;/font&gt;&lt;font id="p5j:" face="Arial, sans-serif"&gt;&lt;font id="vcme" size="2"&gt;&lt;b id="a3ia"&gt; events&lt;/b&gt;&lt;/font&gt;&lt;/font&gt;&lt;/h2&gt;&lt;p id="pofp" class="western" style="margin-bottom: 0in;" lang="da-DK"&gt; &lt;font id="hpx1" face="Arial, sans-serif"&gt;&lt;font id="cwh7" size="2"&gt;There is a bunch of other events that can be necessary to implement to for instance control viewstate etc. These special events can be found in the event hierarchy below.&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;p id="pofp" class="western" style="margin-bottom: 0in;" lang="da-DK"&gt;&lt;font id="hpx1" face="Arial, sans-serif"&gt;&lt;font id="cwh7" size="2"&gt;&lt;br id="wxul"&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;h2 id="ra53"&gt;&lt;font id="kkng" face="Arial, sans-serif"&gt;&lt;font id="zse0" size="2"&gt;&lt;b id="sb5s"&gt;Event hierarchy:&lt;/b&gt;&lt;/font&gt;&lt;/font&gt;&lt;/h2&gt;  &lt;p id="ukdw" class="western" style="margin-bottom: 0in;" lang="en-AU"&gt; &lt;span id="c413" lang="en-US"&gt;&lt;font id="knuf" size="2"&gt;&lt;font id="bhdp" face="Arial, sans-serif"&gt;&lt;i id="i97p"&gt;Instantiate   &lt;/i&gt;Constructor&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p id="kvn:" class="western" style="margin-bottom: 0in;"&gt;&lt;br id="dyg2"&gt; &lt;/p&gt; &lt;p id="g1en" class="western" style="margin-bottom: 0in;" lang="en-AU"&gt; &lt;span id="ccas" lang="en-US"&gt;&lt;font id="szjy" size="2"&gt;&lt;font id="hgmn" face="Arial, sans-serif"&gt;&lt;i id="yhs-"&gt;Initialise &lt;/i&gt;   &lt;/font&gt;&lt;font id="l41w" face="Courier New, monospace"&gt;&lt;font id="gd-8" color="#800000"&gt;OnInit&lt;/font&gt;&lt;/font&gt;&lt;font id="dt1a" face="Arial, sans-serif"&gt; method and Init event&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p id="fe-t" class="western" style="margin-bottom: 0in;"&gt;&lt;br id="pckl"&gt; &lt;/p&gt; &lt;p id="f-bgl" class="western" style="margin-bottom: 0in;" lang="en-AU"&gt; &lt;span id="ycsy" lang="en-US"&gt;&lt;font id="dfje" size="2"&gt;&lt;i id="meha"&gt;&lt;font id="zqp9" face="Arial, sans-serif"&gt;Begin tracking view state &lt;/font&gt;&lt;/i&gt;&lt;font id="fy_y" face="Courier New, monospace"&gt;&lt;font id="ehzv" color="#800000"&gt;TrackViewState&lt;/font&gt;&lt;/font&gt;&lt;font id="qdzc" face="Arial, sans-serif"&gt; method&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p id="qfwm" class="western" style="margin-bottom: 0in;"&gt;&lt;br id="x-qe"&gt; &lt;/p&gt; &lt;p id="m4eq" class="western" style="margin-bottom: 0in;"&gt;&lt;font id="rwty" face="Arial, sans-serif"&gt;&lt;font id="b3ja" size="2"&gt; (PostBack Only)&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;p id="y4ba" class="western" style="margin-bottom: 0in;"&gt;&lt;br id="u7y_"&gt; &lt;/p&gt; &lt;p id="qbqx" class="western" style="margin-bottom: 0in;" lang="en-AU"&gt; &lt;span id="hfbp" lang="en-US"&gt;&lt;font id="xt68" size="2"&gt;&lt;font id="ceeg" face="Arial, sans-serif"&gt; &lt;i id="x2o3"&gt;Load view state  &lt;/i&gt;&lt;/font&gt;&lt;font id="y:ix" face="Courier New, monospace"&gt;&lt;font id="f6t4" color="#800000"&gt;LoadViewState&lt;/font&gt;&lt;/font&gt;&lt;font id="jrtr" face="Arial, sans-serif"&gt; method&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p id="ps1h" class="western" style="margin-bottom: 0in;"&gt; &lt;/p&gt; &lt;p id="gy6b" class="western" style="margin-bottom: 0in;" lang="en-AU"&gt; &lt;span id="ro0o" lang="en-US"&gt;&lt;font id="r6:n" size="2"&gt;&lt;font id="fa6i" face="Arial, sans-serif"&gt; &lt;i id="u5p1"&gt;Load PostBack Data&lt;/i&gt; &lt;/font&gt;&lt;font id="g8z8" face="Courier New, monospace"&gt;&lt;font id="ud92" color="#800000"&gt;IPostBackDataHandler&lt;/font&gt;&lt;/font&gt;&lt;font id="gw.q" face="Arial, sans-serif"&gt;.&lt;/font&gt;&lt;font id="wc-f" face="Courier New, monospace"&gt;&lt;font id="l7ls" color="#800000"&gt;LoadPostData&lt;/font&gt;&lt;/font&gt;&lt;font id="s6q6" face="Arial, sans-serif"&gt; method&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p id="pzgv" class="western" style="margin-bottom: 0in;"&gt;&lt;br id="orjr"&gt; &lt;/p&gt; &lt;p id="auef" class="western" style="margin-bottom: 0in;" lang="en-AU"&gt; &lt;span id="sd-c" lang="en-US"&gt;&lt;font id="cpwk" size="2"&gt;&lt;font id="wnaj" face="Arial, sans-serif"&gt;&lt;i id="d7au"&gt;Load&lt;/i&gt;    &lt;/font&gt;&lt;font id="dbl0" face="Courier New, monospace"&gt;&lt;font id="pjos" color="#800000"&gt;OnLoad&lt;/font&gt;&lt;/font&gt;&lt;font id="q.ds" face="Arial, sans-serif"&gt; method and &lt;/font&gt;&lt;font id="jv4z" face="Courier New, monospace"&gt;&lt;font id="m7-0" color="#800000"&gt;Load&lt;/font&gt;&lt;/font&gt;&lt;font id="t8yr" face="Arial, sans-serif"&gt; event&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p id="x2z6" class="western" style="margin-bottom: 0in;"&gt;&lt;br id="yufl"&gt; &lt;/p&gt; &lt;p id="pll1" class="western" style="margin-bottom: 0in;"&gt;&lt;font id="q::q" face="Arial, sans-serif"&gt;&lt;font id="abq9" size="2"&gt; (PostBack only)&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;p id="vmc6" class="western" style="margin-bottom: 0in;"&gt;&lt;br id="cl.b"&gt; &lt;/p&gt; &lt;p id="trk6" class="western" style="margin-bottom: 0in;" lang="en-AU"&gt; &lt;span id="m970" lang="en-US"&gt;&lt;font id="r3te" size="2"&gt;&lt;font id="k-n1" face="Arial, sans-serif"&gt;&lt;i id="z1u_"&gt; Raise Changed Events&lt;/i&gt; &lt;/font&gt;&lt;font id="rkb:" face="Courier New, monospace"&gt;&lt;font id="k_va" color="#800000"&gt;IPostBackDataHandler&lt;/font&gt;&lt;/font&gt;&lt;font id="hg2-" face="Arial, sans-serif"&gt;.&lt;/font&gt;&lt;font id="uva:" face="Courier New, monospace"&gt;&lt;font id="faob" color="#800000"&gt;RaisePostDataChangedEvent&lt;/font&gt;&lt;/font&gt;&lt;font id="e67." face="Arial, sans-serif"&gt; method&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p id="a-3c" class="western" style="margin-bottom: 0in;"&gt;&lt;br id="cmld"&gt; &lt;/p&gt; &lt;p id="lj3c" class="western" style="margin-bottom: 0in;" lang="en-AU"&gt; &lt;span id="uosd" lang="en-US"&gt;&lt;font id="js88" size="2"&gt;&lt;font id="m3xd" face="Arial, sans-serif"&gt; &lt;i id="l-l5"&gt;Raise PostBack Event&lt;/i&gt; &lt;/font&gt;&lt;font id="b16b" face="Courier New, monospace"&gt;&lt;font id="magp" color="#800000"&gt;IPostBackDataHandler&lt;/font&gt;&lt;/font&gt;&lt;font id="nlec" face="Arial, sans-serif"&gt;.&lt;/font&gt;&lt;font id="h.e5" face="Courier New, monospace"&gt;&lt;font id="zbrd" color="#800000"&gt;RaisePostBackEvent&lt;/font&gt;&lt;/font&gt;&lt;font id="hbm0" face="Arial, sans-serif"&gt; method&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p id="a:9o" class="western" style="margin-bottom: 0in;"&gt;&lt;br id="an5e"&gt; &lt;/p&gt; &lt;p id="xx0o" class="western" style="margin-bottom: 0in;" lang="en-AU"&gt; &lt;font id="n5qx" size="2"&gt;&lt;span id="mxez" lang="da-DK"&gt;&lt;font id="w8c6" face="Arial, sans-serif"&gt;&lt;i id="bvyg"&gt;PreRender&lt;/i&gt;   &lt;/font&gt;&lt;/span&gt;&lt;span id="fmjn" lang="en-US"&gt;&lt;font id="kf3_" face="Courier New, monospace"&gt;&lt;font id="r52h" color="#800000"&gt;OnPreRender&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span id="tjf7" lang="da-DK"&gt;&lt;font id="py53" face="Arial, sans-serif"&gt; method and &lt;/font&gt;&lt;/span&gt;&lt;span id="dov1" lang="en-US"&gt;&lt;font id="a9:y" face="Courier New, monospace"&gt;&lt;font id="u5m3" color="#800000"&gt;PreRender&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span id="ngfv" lang="da-DK"&gt;&lt;font id="qtu0" face="Arial, sans-serif"&gt; event&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p id="ml5a" class="western" style="margin-bottom: 0in;" lang="da-DK"&gt; &lt;br id="a6.q"&gt; &lt;/p&gt; &lt;p id="us26" class="western" style="margin-bottom: 0in;" lang="en-AU"&gt; &lt;span id="kw67" lang="en-US"&gt;&lt;font id="gu77" size="2"&gt;&lt;i id="lhen"&gt;&lt;font id="z-h5" face="Arial, sans-serif"&gt;Save View State  &lt;/font&gt;&lt;/i&gt;&lt;font id="h:2b" face="Courier New, monospace"&gt;&lt;font id="dhx_" color="#800000"&gt;SaveViewState&lt;/font&gt;&lt;/font&gt;&lt;font id="l6bx" face="Arial, sans-serif"&gt; method&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p id="hmiz" class="western" style="margin-bottom: 0in;"&gt;&lt;br id="le80"&gt; &lt;/p&gt; &lt;p id="wuw5" class="western" style="margin-bottom: 0in;" lang="en-AU"&gt; &lt;span id="ah2g" lang="en-US"&gt;&lt;font id="h7s9" size="2"&gt;&lt;font id="f3bg" face="Arial, sans-serif"&gt;&lt;i id="s317"&gt;Render&lt;/i&gt;    &lt;/font&gt;&lt;font id="vwj7" face="Courier New, monospace"&gt;&lt;font id="j_1l" color="#800000"&gt;Render&lt;/font&gt;&lt;/font&gt;&lt;font id="f5ct" face="Arial, sans-serif"&gt; &amp;amp; &lt;/font&gt;&lt;font id="ex0w" face="Courier New, monospace"&gt;&lt;font id="yb7y" color="#800000"&gt;RenderControls&lt;/font&gt;&lt;/font&gt;&lt;font id="snd9" face="Arial, sans-serif"&gt; Method&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p id="pv1g" class="western" style="margin-bottom: 0in;"&gt;&lt;br id="yev3"&gt; &lt;/p&gt; &lt;p id="el_1" class="western" style="margin-bottom: 0in;" lang="en-AU"&gt; &lt;span id="y1li" lang="en-US"&gt;&lt;font id="x.gr" size="2"&gt;&lt;font id="b0_8" face="Arial, sans-serif"&gt;&lt;i id="oyh2"&gt;Unload &lt;/i&gt;   &lt;/font&gt;&lt;font id="wdx0" face="Courier New, monospace"&gt;&lt;font id="pxcr" color="#800000"&gt;OnUnload&lt;/font&gt;&lt;/font&gt;&lt;font id="kpds" face="Arial, sans-serif"&gt; method and &lt;/font&gt;&lt;font id="o6ak" face="Courier New, monospace"&gt;&lt;font id="t5b." color="#800000"&gt;Unload&lt;/font&gt;&lt;/font&gt;&lt;font id="imfw" face="Arial, sans-serif"&gt; event&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p id="s:qf" class="western" style="margin-bottom: 0in;"&gt;&lt;br id="e0vm"&gt; &lt;/p&gt; &lt;p id="qxiv" class="western" style="margin-bottom: 0in;" lang="en-AU"&gt; &lt;span id="sjkz" lang="en-US"&gt;&lt;font id="l-ro" size="2"&gt;&lt;i id="pax5"&gt;&lt;font id="u7bg" face="Arial, sans-serif"&gt;Dispose   &lt;/font&gt;&lt;/i&gt;&lt;font id="x0q9" face="Courier New, monospace"&gt;&lt;font id="pybq" color="#800000"&gt;Dispose&lt;/font&gt;&lt;/font&gt;&lt;font id="q_no" face="Arial, sans-serif"&gt; method&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10978285-8450567801267408322?l=codethings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codethings.blogspot.com/feeds/8450567801267408322/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10978285&amp;postID=8450567801267408322' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10978285/posts/default/8450567801267408322'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10978285/posts/default/8450567801267408322'/><link rel='alternate' type='text/html' href='http://codethings.blogspot.com/2008/04/composite-control-event-in-asp.html' title=''/><author><name>Kaj Bonfils</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_nwFXASfM7G4/SvA7jv27MvI/AAAAAAAAJVs/i8E3nUD2tnI/S220/kboeqa.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10978285.post-7492922431832416789</id><published>2008-04-08T15:58:00.006+02:00</published><updated>2008-10-22T22:01:27.644+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><title type='text'>System.DirectoryServices.AccountManagement namespace</title><content type='html'>The AccountManagement namespace is part of the .Net 3.5 framework, and provides an easy way to access and modify directory services.&lt;br /&gt;&lt;br /&gt;I used to have my own ADHelper library that encapsulated the methods in System.DirectoryServices namespace.&lt;br /&gt;&lt;br /&gt;Recently, i had to find out if a user was member of a specified group. This was possible, but it took a lot of lines of code. With the AccountManagement namespace it can be done in a few lines:&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: Courier New; font-size: 10pt; color: black; background: white;"&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;static&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; Main()&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; UserPrincipal user = UserPrincipal.Current;&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;if&lt;/span&gt; (user == &lt;span style="color: blue;"&gt;null&lt;/span&gt; &amp;amp;&amp;amp; !IsMemberOf(user, Settings.Default.EditorRole))&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;// user is found&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;static&lt;/span&gt; &lt;span style="color: blue;"&gt;bool&lt;/span&gt; IsMemberOf(UserPrincipal user, &lt;span style="color: blue;"&gt;string&lt;/span&gt; roleName)&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;bool&lt;/span&gt; result = &lt;span style="color: blue;"&gt;false&lt;/span&gt;;&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;if&lt;/span&gt; (user != &lt;span style="color: blue;"&gt;null&lt;/span&gt;)&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; PrincipalSearchResult groups = user.GetGroups();&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;if&lt;/span&gt; (groups != &lt;span style="color: blue;"&gt;null&lt;/span&gt;)&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&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;span style="color: blue;"&gt;foreach&lt;/span&gt; (Principal principal &lt;span style="color: blue;"&gt;in&lt;/span&gt; groups)&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&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;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;if&lt;/span&gt; (principal.Name.Equals(roleName, &lt;span style="color: #2b91af;"&gt;StringComparison&lt;/span&gt;.CurrentCultureIgnoreCase))&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; result = &lt;span style="color: blue;"&gt;true&lt;/span&gt;;&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;break&lt;/span&gt;;&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&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;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;return&lt;/span&gt; result;&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10978285-7492922431832416789?l=codethings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codethings.blogspot.com/feeds/7492922431832416789/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10978285&amp;postID=7492922431832416789' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10978285/posts/default/7492922431832416789'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10978285/posts/default/7492922431832416789'/><link rel='alternate' type='text/html' href='http://codethings.blogspot.com/2008/04/systemdirectoryservicesaccountmanagemen.html' title='System.DirectoryServices.AccountManagement namespace'/><author><name>Kaj Bonfils</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_nwFXASfM7G4/SvA7jv27MvI/AAAAAAAAJVs/i8E3nUD2tnI/S220/kboeqa.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10978285.post-5534933302641413935</id><published>2008-03-06T11:20:00.004+01:00</published><updated>2008-12-12T04:20:50.258+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><title type='text'>Clean up the Using blog in Visual Studio 2008</title><content type='html'>When you create a new class, its normally filled with using statements in the top. Usually you only use one or two of these statements. &lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;Visual Studio 2008 has a great feature for cleaning up the code:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;ol&gt;&lt;li&gt;Right click somewhere in the editor&lt;/li&gt;&lt;li&gt;Select "Organise Usings"&lt;/li&gt;&lt;li&gt;Select "Remove and Sort"&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;This removes unused Usings and stort them. You can also choose to only remove unused usings or to sort the using statements.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;a href="http://3.bp.blogspot.com/_nwFXASfM7G4/R8_GCwVKbaI/AAAAAAAADQ8/cHb6rVz5T9E/s1600-h/CleanUpUsing1.jpg"&gt;&lt;img id="BLOGGER_PHOTO_ID_5174572247507692962" style="FLOAT: left; MARGIN: 0px 10px 10px 0px; CURSOR: hand" alt="" src="http://3.bp.blogspot.com/_nwFXASfM7G4/R8_GCwVKbaI/AAAAAAAADQ8/cHb6rVz5T9E/s320/CleanUpUsing1.jpg" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://3.bp.blogspot.com/_nwFXASfM7G4/R8_GLwVKbbI/AAAAAAAADRE/QL5TW0ifiqc/s1600-h/CleanUpUsing2.jpg"&gt;&lt;img id="BLOGGER_PHOTO_ID_5174572402126515634" style="FLOAT: right; MARGIN: 0px 0px 10px 10px; CURSOR: hand" alt="" src="http://3.bp.blogspot.com/_nwFXASfM7G4/R8_GLwVKbbI/AAAAAAAADRE/QL5TW0ifiqc/s320/CleanUpUsing2.jpg" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10978285-5534933302641413935?l=codethings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codethings.blogspot.com/feeds/5534933302641413935/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10978285&amp;postID=5534933302641413935' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10978285/posts/default/5534933302641413935'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10978285/posts/default/5534933302641413935'/><link rel='alternate' type='text/html' href='http://codethings.blogspot.com/2008/03/clean-up-using-blog-in-visual-studio.html' title='Clean up the Using blog in Visual Studio 2008'/><author><name>Kaj Bonfils</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_nwFXASfM7G4/SvA7jv27MvI/AAAAAAAAJVs/i8E3nUD2tnI/S220/kboeqa.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_nwFXASfM7G4/R8_GCwVKbaI/AAAAAAAADQ8/cHb6rVz5T9E/s72-c/CleanUpUsing1.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10978285.post-5793220931822561504</id><published>2007-09-24T15:56:00.000+02:00</published><updated>2007-09-24T16:05:35.295+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><title type='text'>?? operator</title><content type='html'>I just discovered a new Operator in .Net 2.0...&lt;br /&gt;&lt;br /&gt;the ?? operator.&lt;br /&gt;&lt;br /&gt;One of the most anoing things to do when retrieving data, is checking for null values:&lt;br /&gt;&lt;br /&gt;string myValue = dataReader.IsDBNull(2) ? string.Empty : dataReader.GetString(2);&lt;br /&gt;&lt;br /&gt;But the ?? operator makes it a lot easier:&lt;br /&gt;&lt;br /&gt;string myValue = dataReader.GetString(2)??string.Empty;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#ff0000;"&gt;Why didn't anybody tell me about this before?????&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff0000;"&gt;&lt;/span&gt;&lt;br /&gt;Read more here : &lt;a href="http://msdn2.microsoft.com/en-us/library/ms173224(VS.80).aspx"&gt;http://msdn2.microsoft.com/en-us/library/ms173224(VS.80).aspx&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10978285-5793220931822561504?l=codethings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codethings.blogspot.com/feeds/5793220931822561504/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10978285&amp;postID=5793220931822561504' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10978285/posts/default/5793220931822561504'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10978285/posts/default/5793220931822561504'/><link rel='alternate' type='text/html' href='http://codethings.blogspot.com/2007/09/operator.html' title='?? operator'/><author><name>Kaj Bonfils</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_nwFXASfM7G4/SvA7jv27MvI/AAAAAAAAJVs/i8E3nUD2tnI/S220/kboeqa.jpg'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10978285.post-2883641327748598384</id><published>2007-08-28T12:24:00.000+02:00</published><updated>2007-08-31T09:08:48.411+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><title type='text'>Sorting a List&lt;&gt; object using different sort criterias</title><content type='html'>I have often had a list of objects that i need to sort. This can easyly be done through a SortedList&lt;key,&gt;, but this will only sort on the provided key. I would like to descide if i want to sort by my object.Property1 or object.Property2, ascending or descending etc. Also the SortedList&lt;key,&gt; give me problems if i have multiple objects with the same sort-ordinal.&lt;br /&gt;&lt;br /&gt;The List&lt;&gt; type has a method, List&lt;&gt;.Sort(...) that can help out on this. In the example below, I have implemented a Person class, a PersonCollection : List&lt;person&gt; and a PersonComparer : IComparer&lt;person&gt; class. The PersonComparer has a constructor that takes a sortorder and a sortdirection as parameters. Calling the mypersonlist.Sort(...) method takes this PersonComparer object and carries out the actual sorting:&lt;br /&gt;&lt;span style="font-size:85%;color:#ff0000;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;font-size:85%;color:#009900;"&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;using System;&lt;br /&gt;using System.Collections.Generic;&lt;br /&gt;using System.Text;&lt;br /&gt;namespace SortingExample&lt;br /&gt;{&lt;br /&gt;        class Program&lt;br /&gt;        {&lt;br /&gt;                static void Main(string[] args)&lt;br /&gt;                {&lt;br /&gt;                        // Create a friendscollection&lt;br /&gt;                        PersonCollection friends = new PersonCollection();&lt;br /&gt;                        friends.Add(new Person("Kaj", 32));&lt;br /&gt;                        friends.Add(new Person("Frank", 33));&lt;br /&gt;                        friends.Add(new Person("Morten", 42));&lt;br /&gt;                        Console.WriteLine("Age, Asc");&lt;br /&gt;                        // Sort by age asc&lt;br /&gt;                        PersonComparer sorter = new PersonComparer(PersonSort.Age, SortDirection.Ascending);&lt;br /&gt;                        friends.Sort(sorter);&lt;br /&gt;                        PrintNames(friends);&lt;br /&gt;                        Console.WriteLine("Age, Desc");&lt;br /&gt;                        // Sort by age desc&lt;br /&gt;                        sorter.SortDirection = SortDirection.Descending;&lt;br /&gt;                        friends.Sort(sorter);&lt;br /&gt;                        PrintNames(friends);&lt;br /&gt;                        Console.WriteLine("Name, Asc");&lt;br /&gt;                        // Sort by name asc&lt;br /&gt;                        sorter.SortDirection = SortDirection.Ascending;&lt;br /&gt;                        sorter.Sort = PersonSort.Name;&lt;br /&gt;                        friends.Sort(sorter);&lt;br /&gt;                        PrintNames(friends);&lt;br /&gt;                        Console.WriteLine("Name, Desc");&lt;br /&gt;                        // Sort by name desc&lt;br /&gt;                        sorter.SortDirection = SortDirection.Descending;&lt;br /&gt;                        friends.Sort(sorter);&lt;br /&gt;                        PrintNames(friends);&lt;br /&gt;                }&lt;br /&gt;&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;font-size:85%;color:#009900;"&gt;&lt;code&gt;                /// &lt;summary&gt;&lt;br /&gt;                /// Printing out the persons of a PersonCollection&lt;br /&gt;                /// &lt;/summary&gt;&lt;br /&gt;                /// &lt;param name="persons"&gt;A list of persons.&lt;/param&gt;&lt;br /&gt;                public static void PrintNames(PersonCollection persons)&lt;br /&gt;                {&lt;br /&gt;                        foreach (Person friend in persons)&lt;br /&gt;                        {&lt;br /&gt;                                Console.WriteLine(string.Format("{0} - {1} years", friend.Name, friend.Age));&lt;br /&gt;                        }&lt;br /&gt;                }&lt;br /&gt;        } &lt;/code&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;font-size:85%;color:#009900;"&gt;&lt;code&gt;&lt;br /&gt;        /// &lt;summary&gt;&lt;br /&gt;        /// The personobject will hold info about a person.&lt;br /&gt;        /// &lt;/summary&gt;&lt;br /&gt;        public class Person&lt;br /&gt;        {&lt;br /&gt;                private string _name;&lt;br /&gt;                private int _age;&lt;br /&gt;               &lt;br /&gt;                /// &lt;summary&gt;&lt;br /&gt;                /// The name of the person.&lt;br /&gt;                /// &lt;/summary&gt;&lt;br /&gt;                public string Name&lt;br /&gt;                {&lt;br /&gt;                        get { return _name; }&lt;br /&gt;                        set { _name = value; }&lt;br /&gt;                }&lt;br /&gt;&lt;br /&gt;                /// &lt;summary&gt;&lt;br /&gt;                /// The age of the person.&lt;br /&gt;                /// &lt;/summary&gt;&lt;br /&gt;                public int Age&lt;br /&gt;                {&lt;br /&gt;                        get { return _age; }&lt;br /&gt;                        set { _age = value; }&lt;br /&gt;                }&lt;br /&gt;&lt;br /&gt;                /// &lt;summary&gt;&lt;br /&gt;                /// Initialize the person object with a name and an age.&lt;br /&gt;                /// &lt;/summary&gt;&lt;br /&gt;                /// &lt;param name="name"&gt;The name of the person.&lt;/param&gt;&lt;br /&gt;                /// &lt;param name="age"&gt;The age of the person.&lt;/param&gt;&lt;br /&gt;                public Person(string name, int age)&lt;br /&gt;                {&lt;br /&gt;                        Name = name;&lt;br /&gt;                        Age = age;&lt;br /&gt;                }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        /// &lt;summary&gt;&lt;br /&gt;        /// A list of persons...&lt;br /&gt;        /// &lt;/summary&gt;&lt;br /&gt;        public class PersonCollection : List&lt;person&gt;&lt;br /&gt;        {&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        /// &lt;summary&gt;&lt;br /&gt;        /// The different sort orders&lt;br /&gt;        /// &lt;/summary&gt;&lt;br /&gt;        public enum PersonSort&lt;br /&gt;        {&lt;br /&gt;                Name,&lt;br /&gt;                Age&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        /// &lt;summary&gt;&lt;br /&gt;        /// Sort direction&lt;br /&gt;        /// &lt;/summary&gt;&lt;br /&gt;        /// &lt;remarks&gt;The emum values are used for multiplying on a compare result.&lt;br /&gt;        /// This makes descending sorts appear in reverse order.&lt;br /&gt;        /// &lt;/remarks&gt;&lt;br /&gt;        public enum SortDirection&lt;br /&gt;        {&lt;br /&gt;                Ascending = 1,&lt;br /&gt;                Descending = -1&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        /// &lt;summary&gt;&lt;br /&gt;        /// This class takes care of comparing two persons. The&lt;br /&gt;        /// class uses sorting and sort direction to determine which&lt;br /&gt;        /// of the two objects has the highest value.&lt;br /&gt;        /// &lt;/summary&gt;&lt;br /&gt;        public class PersonComparer : IComparer&lt;person&gt;&lt;br /&gt;        {&lt;br /&gt;                private PersonSort _sort;&lt;br /&gt;                private SortDirection _sortDirection;&lt;br /&gt;                public PersonSort Sort&lt;br /&gt;                {&lt;br /&gt;                        get { return this._sort; }&lt;br /&gt;                        set { this._sort = value; }&lt;br /&gt;                }&lt;br /&gt;                public SortDirection SortDirection&lt;br /&gt;                {&lt;br /&gt;                        get { return this._sortDirection; }&lt;br /&gt;                        set { this._sortDirection = value; }&lt;br /&gt;                }&lt;br /&gt;&lt;br /&gt;                public PersonComparer(PersonSort sort, SortDirection direction)&lt;br /&gt;                {&lt;br /&gt;                        this._sort = sort;&lt;br /&gt;                        this._sortDirection = direction;&lt;br /&gt;                }&lt;br /&gt;                #region IComparer&lt;person&gt; Members&lt;br /&gt;                public int Compare(Person x, Person y)&lt;br /&gt;                {&lt;br /&gt;                        if (_sort == PersonSort.Age)&lt;br /&gt;                        {&lt;br /&gt;                        return x.Age.CompareTo(y.Age)*(int)_sortDirection;&lt;br /&gt;                        }&lt;br /&gt;                        else&lt;br /&gt;                        {&lt;br /&gt;                        return x.Name.CompareTo(y.Name)*(int)_sortDirection;&lt;br /&gt;                        }&lt;br /&gt;                }&lt;br /&gt;                #endregion&lt;br /&gt;        }&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10978285-2883641327748598384?l=codethings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codethings.blogspot.com/feeds/2883641327748598384/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10978285&amp;postID=2883641327748598384' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10978285/posts/default/2883641327748598384'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10978285/posts/default/2883641327748598384'/><link rel='alternate' type='text/html' href='http://codethings.blogspot.com/2007/08/sorting-list-object-using-different.html' title='Sorting a List&lt;&gt; object using different sort criterias'/><author><name>Kaj Bonfils</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_nwFXASfM7G4/SvA7jv27MvI/AAAAAAAAJVs/i8E3nUD2tnI/S220/kboeqa.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10978285.post-4808306800183692379</id><published>2007-08-22T12:49:00.000+02:00</published><updated>2007-08-22T13:00:09.353+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><category scheme='http://www.blogger.com/atom/ns#' term='Code Analysis'/><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><title type='text'>How to avoid Code Analysis CA1002</title><content type='html'>I recently made some code like this:&lt;br /&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;public class MenuItem &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;  private List&lt;menuitem&gt; _subItems;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;  public List&lt;menuitem&gt; SubItems &lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;  {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;    get { return _subItems;}&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;  }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;  ... ...&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Arial;"&gt;This caused Code Analysis to throw a CA1002 warning - Do not expose generic lists.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Arial;"&gt;(see ms help: &lt;a href="http://msdn2.microsoft.com/en-us/library/ms182142(VS.90).aspx"&gt;http://msdn2.microsoft.com/en-us/library/ms182142(VS.90).aspx&lt;/a&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Arial;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Arial;"&gt;The help didn't help much, but i solved it pretty simply by making a class that inherits the List generic class:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Arial;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;public class MenuItemCollection : List&lt;menuitem&gt; &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;public class MenuItem&lt;br /&gt;{&lt;br /&gt;  private MenuItemCollection _subItems;&lt;br /&gt;&lt;br /&gt;  public MenuItemCollection SubItems&lt;br /&gt;  {&lt;br /&gt;    get { return _subItems;}&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  ... ...&lt;br /&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;font-size:78%;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;This will avoid the CA1002 warning. Remember to name the collection class "Collection" in the end. Otherwise you will get a CA1710 warning, Identifies should have correct suffix. (&lt;a href="http://msdn2.microsoft.com/en-us/library/ms182244(VS.90).aspx"&gt;http://msdn2.microsoft.com/en-us/library/ms182244(VS.90).aspx&lt;/a&gt;)&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10978285-4808306800183692379?l=codethings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codethings.blogspot.com/feeds/4808306800183692379/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10978285&amp;postID=4808306800183692379' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10978285/posts/default/4808306800183692379'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10978285/posts/default/4808306800183692379'/><link rel='alternate' type='text/html' href='http://codethings.blogspot.com/2007/08/how-to-avoid-code-analysis-ca1002.html' title='How to avoid Code Analysis CA1002'/><author><name>Kaj Bonfils</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_nwFXASfM7G4/SvA7jv27MvI/AAAAAAAAJVs/i8E3nUD2tnI/S220/kboeqa.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-10978285.post-110898085502349798</id><published>2005-02-21T11:00:00.000+01:00</published><updated>2007-08-31T09:09:10.498+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint Portal Server'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><title type='text'>Export of Sharepoint Profile properties</title><content type='html'>I have to export the properties from on Sharepoint environment to another (from development to production).&lt;br /&gt;In my development environment, i create the properties i need directly in the Sharepoint administration interface. When everything is approved, i export the properties directly in the SQL server. This is done by copying part of the contents from Profile database on the development environment to the production environment. The informations about the profiles are stored in these tables:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;PropertyList&lt;/li&gt;&lt;li&gt;ProfileUI&lt;/li&gt;&lt;li&gt;DataServicePropMap&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;The propertyList table contains the actual definitions of the properties. The profileUI contains information about the presentation of the property, both in edit and presentationmode. The DataServicePropMap is used to map AD fields to the values of the properties. &lt;/p&gt;&lt;p&gt;Note that the values of the users isn't exported by using this method.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/10978285-110898085502349798?l=codethings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codethings.blogspot.com/feeds/110898085502349798/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=10978285&amp;postID=110898085502349798' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10978285/posts/default/110898085502349798'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10978285/posts/default/110898085502349798'/><link rel='alternate' type='text/html' href='http://codethings.blogspot.com/2005/02/export-of-sharepoint-profile.html' title='Export of Sharepoint Profile properties'/><author><name>Kaj Bonfils</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_nwFXASfM7G4/SvA7jv27MvI/AAAAAAAAJVs/i8E3nUD2tnI/S220/kboeqa.jpg'/></author><thr:total>1</thr:total></entry></feed>
