ASP.NET

Custom Scrollbar Styling

This has got to be one of the best scrollbar styling plugins for jQuery I have come across to date… It is stable and highly customizable. 

http://manos.malihu.gr/jquery-custom-content-scroller

I spent hours … literally HOURS! … trying different plugins to style my scrollbars. This thing was a Godsend!

I’m not supporting Internet Explorer anymore…

I have been working pretty hard on a new project which brings back some very old Internet functionality, but I am hoping to do it right. I plan to do this by not screwing people and by looking at the problem for what it truly is. Provide a great UI for something that everyone would love to have and use but has largely been ignored, and stay the f**k out of the way of the users. You know … help them!

However that is not what this blog post is about. This post is about why I will no longer support Internet Explorer older than IE9 or even consider what it does as it interprets CSS/HTML. So here goes …

IE has been losing market share at an alarming rate. If I worked for Microsoft I would seriously wonder about what I could do with that project since the numbers are very clearly showing that it is failing. Here are the latest numbers from W3 Schools a site I use quite a bit for how-to and other things

 

2012 Internet Explorer Firefox Chrome Safari Opera
June 16.7 % 34.4 % 41.7 % 4.1 % 2.2 %
May 18.1 % 35.2 % 39.3 % 4.3 % 2.2 %
April 18.3 % 35.8 % 38.3 % 4.5 % 2.3 %
March 18.9 % 36.3 % 37.3 % 4.4 % 2.3 %
February 19.5 % 36.6 % 36.3 % 4.5 % 2.3 %
January 20.1 % 37.1 % 35.3 % 4.3 % 2.4 %

 

The numbers very clearly demonstrate that I will lose 16.7% of my potential clients. That is a total number of IE users. So I would hope a good deal of them are on IE9. However, let's just say that we split that percentage between 7/8/9, I would miss out on about 11%. I think that this is an acceptable loss, not to mention that I will attempt to steer them toward Chrome. So at the end of the day I may lose about 8% of clients due to this choice. Again this is acceptable. 

We also have to consider the IE drop rate. In one month IE lost 1.4% market share. THAT IS HUGE !! Chrome gained 2.4 … 

No I don't hate Microsoft…

All that being said someone reading this may wonder if I really despise Microsoft, love Apple and think the world should just hold hands and be friends. Well I don't fall into any of those stereotypes. I am writing this application using Visual Studio 2012, ASP.NET MVC 4 … I could write an entire post as to why Microsoft is beating the pants off of any other Dev tools provider out there, but that's for later.

So if I'm not an Apple fanboi or some kind of hippie, why am I hating on IE? The answer is simple…. IT'S UNSTABLE!

You're thinking I'm talking about it crashing, loading slow, having security flaws,etc. Well I am not. I am referring to it's poor backward compatibility, the obvious shortcomings when it comes to following industry standards and the list goes on. However the kicker for me is the gargantuan amount of effort I would have to put in to support older versions of this browser. It's not worth the trouble. 

Need it summed up?

IE versions older than 9 are not developer friendly. Period. 

I wish I could talk to Steve Balmer 1 on 1 … 

You're probably thinking I would give him an earful, and "let him have it" … well that's not the case. Microsoft is a great company, I would hate to seem them go the way of IBM ( I do HATE!!!! IBM with a deep dark burning passion of sheer red hot hate ! ) … ahem … 

I see Microsoft as the 75% company, they never finish anything. Many products that could have had amazing impact and continued to innovate were allowed to slowly die. Here's a small list:

  • Zune
  • Silverlight
  • LINQ
  • BizTalk Server

Those are in no particular order and off the top of my head. Let's examine one whose mishandling REALLY disappointed me… Silverlight.

I loved this idea! A small installable framework that could deliver rich apps to my users!?! That would be amazing! However it suffered from what I see as lack of interest. The whole company did not get behind the movement and provide the AMAZING dev platform that Visual Studio became. WHY!!? 

I know Silverlight 5 is coming out, but I have heard a great many people say that Silverlight is dead. That is really sad.

So what would I say to Steve Balmer? Believe in your company, your people and your products. Silverlight could have been great, heck it still could ( please don't drag up HTML5/JS assuming I'm not aware is ignorant ). Silverlight could be more than a video player. 

 

The point ?

Microsoft needs to believe in their products, stabilize them and follow industry standard or I believe more developers will follow in my footsteps.

Agree/Disaggree ?  Am I wrong ? Not seeing something ? … Leave a comment

 

Simple … Very Simple DIV vertical alignment

OH MY DEAR !! 

I have spent countless hours in the past trying to figure out how to vertically align the contents of a DIV element using CSS… I am a CSS noob of sorts. I know the syntax but I don't know all the hacks and tricks. 

So here's how:

HTML:

 

<div class="navigation_tile">
    <div>
        <img src="@Url.Content("~/Content/images/nav_tile.png")" alt="View" title="View" />
    </div>
</div>

 

 

CSS:

 

.navigation_tile
{
    background-image:url(images/nav_tile.png);
    background-position:bottom;
    background-repeat:repeat-x; 
    height:49px;
}
 
.navigation_tile div
{
    height:49px;
    width:54px;
    vertical-align: middle;
    display:table-cell;"    
}
 

 

Why Does This Work?

Simple explanation is that vertical-align:middle only works for <td> elements. There's a whole inline element discussion I could get into but you don't give a shit. 

Setting the inner div(s) to have a display:table-cell will make it so that vertical-align works since it will be treated as a table cell. 

The reason you need an inner div is because you don't want the container div behaving like a table cell. That screws all sorts of crap up. 

 

Cheers !

Easy RSS For ASP.NET

There’s two sides to this coin.

A) I fill the page with crap and please the search engines.

B) I give you the links and code.

We’ll go with B.

Check out Scott Gu’s blog for his post on an easy RSS reader for ASP.NET.

The blog points to a guy on the ASP.NET team that wrote an easy RSS Toolkit.

I know it’s old… but it helped me. I have an evil SEO plan and this is part of it.

Directions for use of this library:

1) It comes with the following directory structure:
RSS Feed Folder Structure

2) Open Command Prompt.

3) Go to the RssToolkit-1-0-0-1\bin directory and execute the following command:
Rssdl.exe “feed address here” myFeed.cs

4) Reference RssToolkit.dll in your project.

5) Add the myFeed.cs class to your project.

6) Read the RSS feed into the object like this:

myFeedChannel mf = myFeedChannel.LoadChannel();

7) Bind to a grid or just read the thing:

Response.Write(mf.Items[0].ContentEncoded);

Calling Remove From For Each Loop in .NET

I recently had this problem where I needed to do something to all the items of a certain type in a collection, remove them and continue through what was left.

This error was the result of my endeavors:
System.InvalidOperationException: Collection was modified; enumeration operation might not execute.

I wasn’t looking for lengthy writeups so here’s the code:

Before With For Loop:

   1:  Dim curLst As List(Of String)
   2:   
   3:  For Each item As String In BigStringLst
   4:   
   5:      curLst = BigStringLst.FindAll(AddressOf FindResult)
   6:   
   7:      ' DO SOMETHING WITH YOUR LIST OF STRINGS
   8:      ' AND THE CURRENT ITEM
   9:   
  10:      BigStringLst.RemoveAll(AddressOf FindResult)
  11:   Next

What you’re actually looking to do is use a While loop and remove the items. So while you still have items you want to keep processing. The “Next” item is simply the first item in the collection since the collection is shrinking.

After with While Loop:

   1:  Dim curLst as List(Of String)
   2:   
   3:  While BigStringLst.Count > 0
   4:     Dim item As String = upcLst(0)
   5:   
   6:     curLst = BigStringLst.FindAll(AddressOf FindResult)
   7:   
   8:     ' DO SOMETHING WITH YOUR LIST OF STRINGS
   9:   
  10:     BigStringLst.RemoveAll(AddressOf FindResult)
  11:   
  12:  End While
  13:   

Here is the code for the predicate function used in FindAll and RemoveAll for the List(Of String):

  1:  Private Function FindResult(ByVal item As String) As Boolean
  2:     Return (item = "virtualadrian.com")
  3:  End Function

This code was done for folks that want VB.NET so if you want to get this in C# just use a converter. I prefer this one :

http://www.developerfusion.com/tools/convert/vb-to-csharp/

PS: Obviously I wasn’t searching for strings or doing the simple stuff the example shows. However you should get the idea. Also I wrote this up in Notepad so.. watch for syntax errors :0)

Good Luck !