Posts

A footnote on Prototype's Event.observe and mouseover / mouseout

Bild
Recently I worked on a website that had a CSS-based nested navigation and a form. The good old IE6 select overlay bug made it necessary to create an event handler that overlays the select box with an inline-frame (this is a common fix I have read about). To demonstrate the effect, I have set the form to invisible in this example. Mouseout looks like this: Mouseover then hides the form: First I used Prototype's Event.observe(): Event.observe(window, 'load', function() { if(navigator.appVersion.indexOf('MSIE 6.0') != -1){ Event.observe($('mainnavlist'), 'mouseover', function() { $('form1').style.visibility = 'hidden'; }); Event.observe($('mainnavlist'), 'mouseout', function() { $('form1').style.visibility = 'visible'; }); } }; Unsatisfyingly, this caused a lot of visual flickering.Eventually I found out that Event.observe interprets the event a bit different th...

A wonderful IE6 PNG-Fix for everyone

No words, just a single link: http://labs.unitinteractive.com/unitpngfix.php

Hosting any control in a ToolStrip

When using ToolStrips, you soon discover that not many Classes of items can be added regularly. There is a simple way of adding any kind of Control to a ToolStrip by using the ToolStripControlHost class: ToolStrip ts = new ToolStrip(); ts.Items.Add( new ToolStripControlHost( new DateTimePicker())); However, there is NO design-time support for this. jfo has described how to add design-time support on his blog . I have tried this with a DateTimePicker Control and experienced strange Designer behaviour (The Designer show DTP as a permitted Item Type but when I select it, it disappears immediately. Another unexpected behaviour occurs in case of some third-party controls. If, for example, you add a Janus CalendarCombo to a ToolStripControlHost, the control vanishes and the ControlHost fails to show. Effectively, you've just lost a control :) After some research on the Janus Website, I found out that you have to set the hosting element's AutoSize Property to False. ToolStrip ts = new...

Get the Date-String (and only that) from a DateTime

Up to now, whenever I tried to get today's date in C#, I used DateTime.Today and started chopping away the time information using substrings. However, the DateTime type offers a method ToShortDateString() that does exactly what I did in three lines before PLUS it is hooked up with the thread's current culture. // old version, works for de-DE only DateTime.Now.ToString(new CultureInfo("de-DE")).Substring( 0, 10 ); // new version, culture safe DateTime.Now.ToShortDateString(); More useful DateTime stuff can be found here .

Using distinct members of anonymous object-type instances

Sometimes it may happen that you have to set property values on objects depending on whether they exist or not. I though this was feasible using interfaces, but objects can only be checked against contracted interfaces (i.e. such interfaces that occur in the object's class hierarchy), so this is no good here. An easy way to achieve this is the type.GetProperty() and type.GetProperty().SetValue() methods, as explained below. PropertyInfo pi = obj.GetType().GetProperty("Enabled"); bool enablable = (pi != null && pi.PropertyType.Equals(typeof(bool))); if (enablable) { obj.GetType().GetProperty( "Enabled" ).SetValue( obj, true, null ); } The very same thing can also be done with events, methods, fields, nested classes etc. See the following example for an event handler implementation: EventInfo ei = obj.GetType().GetEvent("Paint"); bool paintable = (ei != null); if (paintable) { PaintEventHandler pe = _Paint; obj.GetType().GetEvent("P...

Microsoft Exam 70-505 Self-Paced Training Kit

Bild
To complete my MCTS, I currently study for 70-505. As I said about 70-536, the SPT is the best way to learn. Here comes the but: The mock exam is so faulty that you have to be very careful using it.I will update this post once Microsoft has put up a knowledge base site for this book and my errors have been submitted. UPDATE : And here it is! Edit : After having taken the exam yesterday, I can tell for sure that using only the Self Paced Training Kit may result in a somewhat close call. Sure it helped me get through, but not as good as 70-536 (Score : 828). I think the Microsoft Official Classroom Course may have been of some use, eventually...Anyway, now I have the right to officially use these credentials: If that ain't hot...

Preparing for and passing MCTS exam 70-536

Bild
Today, I passed my Microsoft 70-536 exam. More or less successful, I scored 894 (700 being the passing score) in a bit less than 90 minutes. After reading how much has already been said about this exam, I can summarize: - It does cover a very vast set of topics (the whole .NET-Framework), but only has a few questions for each. - The exam itself is rather short, containing no more than 40 questions. If you are getting many easy questions, this is an advantage. Otherwise... - Only really well-aimed preparation will make you fit for this. Just like a driver's license test, really. Eventually I have to admit that - although I have learned a lot during the preparation phase for this exam - I still wouldn't voluntarily mess around with many of the aspects it covered (like Security Zones or CAS-Policies). I just know they exist and that's about it. Preparation tips Exam preparation seems to be one of the many things, people are willing to spend money on. Many websites offer PDF-Fi...