Author Results

Using jQuery with ASP.NET Controls

Thursday, August 6th, 2009

jQuery, a lightweight (only 19kb in size) JavaScript library has become my new best friend. It’s like mushrooms to Mario. Obviously I’m not alone since Microsoft is now distributing jQuery with Visual Studio (including jQuery intellisense). If you are using the new MVC framework from Microsoft then you will no doubt become familiar with the intricate workings of jQuery.

jQuery is not all that difficult to learn. The biggest thing you have to understand is all the different “selectors” that are available to you. Using selectors developers can query, in a CSS like way, for HTML elements, and then apply “commands” to them.

For example, the below JavaScript uses jQuery to find a <div> element within a page that has a CSS id of “rightSide”, and shows it and “leftSide” and hides it.

  1. $('div#rightSide').show();
  2. $('div#leftSide').hide();

As another example, the JavaScript below uses jQuery to find a specific <table> on the page with an id of “datagrid1”, then retrieves every other <tr> row within the datagrid, and sets those <tr> elements to have a CSS class of “even” – which could be used to alternate the background color of each row:

  1. $('#datagrid1 tr:nth-child(even)').addClass('even');

This next example gets all links <a> in a specific <div> and attaches an onclick event to them:

  1. $('#navBtns a').bind('click', function(event){
  2.      event.preventDefault(); //stop the link from going to href
  3.      //do something
  4. });

Being able to traverse the DOM and locate HTML elements to attach events, behaviors, animations and CSS is priceless. But what about ASP.NET controls like the RadioButtonList, GridView, ListView, Repeater, and many others that we as developers like to bind to? How do we traverse them when they all get their ids auto-generated? That’s what we will look at now! And with jQuery it’s not that hard!

(more…)

Stop And Smell The Roses

Wednesday, July 1st, 2009

“He emerged from the metro at the L’Enfant plaza station and positioned himself against a wall beside a trash basket. By most measures, he was nondescript: a youngish white man in jeans, a long-sleeved T-shirt and a Washington Nationals baseball cap. From a small case, he removed a violin. Placing the open case at his feet, he shrewdly threw in a few dollars and pocket change as seed money, swiveled it to face pedestrian traffic, and began to play.”

This scene is all too familiar for those of us that work in an urban downtown area. Do we stop and listen or just hurry on about our business?

But wait, this was not your typical panhandler. No one knew it, but the fiddler standing against a bare wall was one of the finest classical musicians in the world. In fact, the musician was Joshua Bell. Whom just three days before he appeared at the Metro station, had filled the house at Boston’s stately Symphony Hall, where merely pretty good seats went for $100. The very violin that he played was worth more than most of the passer byes would make in their lifetime. The violin was handcrafted in 1713 by Antonio Stradivari and the price tag was reported to be about $3.5 million.

Joshua Bell, one of the worlds top classical musicians, equipped with his million dollar Stradivari violin played one of the most difficult violin pieces ever. AND THE WORLD WAS TOO BUSY TO NOTICE…

This experiment arranged by The Washington Post struck a cord in me. Probably because I fear that I would be one of the many that was too busy with life to see or hear the beauty that was right there in front of me.

This is one of the reasons for the less frequency of blog post these days. The other reason is the birth of my second child. In the words of Ferris Bueller, “Life moves pretty fast. If you don’t stop and look around once in a while, you could miss it.”

The life of a software developer is fast paced for sure, maybe that’s why they call them sprints in the Agile dev methodology. Make sure you are stopping from time to time to smell the roses or hear the music. Work to live. Don’t live to work…

Be sure to read the entire Washington Post experiment here. It’s well worth your time.

jQuery Dropdown Menu

Tuesday, March 17th, 2009

In this short article we will use jQuery to produce this dropdown menu. Over the past six months I have been using a lot of jQuery and have fallen in love with it. For those not familiar with jQuery it is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. All this and for only 19KB! How nice is that? They claim that, “jQuery will change the way that you write JavaScript.” And they are right. Companies such as Google, Dell, Bank of America, Major League Baseball, Digg, NBC, CBS, Netflix, Technorati, WordPress, Drupal, Mozilla and many others use jQuery too. Ok, that’s enough of a plug, let’s look at the code:

(more…)

ASP.NET – Sending Email Both in HTML and Plain Text

Thursday, February 5th, 2009

In this article you will learn how to send email using ASP.NET. Yes, there are plenty of other articles that cover sending email via .NET, but after spending a day doing research, I was amazed at how many articles failed to provide either a correct solution or a real world example. I found that many articles suggest you create your HTML email by using a string with the HTML markup in it. That’s crazy and not at all a real world solution, at least not for most situations. In this article we will look at a more realistic solution. One in which we use a regular HTML file as our template for the email. The template file will be a standard HTML file with the exception of some placeholders that we will use to populate our content and images right before we send the email. Think mail-merge in Microsoft Word. Finally, we will also learn how to send the email in such a way that if the email recipient’s mail-client can’t render HTML they will get an alternate plain text version.

Let’s start by looking at the code in its entirety; the people that just want to grab the code and use it can do so. I will then explain the code.

(more…)

Oh, The Irony…

Monday, January 26th, 2009

So this morning I thought I would take a look at some of the videos that showcase Windows 7. Maybe get excited about some of the new features, get my hopes up, why not? I went to their website but CAN’T view the videos!

First I get the, “Additional plugins are required to display all the media on this page.” bar, which is not a problem in and of itself. I realize I need to get the Silverlight plugin. So I try to do so and get this error message.


win7a

[ Click to enlarge ]

I’m not going to switch browsers in order to view videos people…

Oh Microsoft, why do you do this to yourself? I can’t keep defending you forever…

This Just In – The Internet Is Popular

Friday, January 16th, 2009

The Internet has now surpassed all media except television as a news source, according to consumers surveyed in December 2008 by the Pew Research Center for the People and the Press.

In December 2008, 40% of respondents said they got most of their news about national and international issues from the Internet, up from just 24% in September 2007.

Pew said it was the first time since it started surveying that consumers relied more on the Internet for news than on newspapers.

Television was still the main source for national and international news, at 70%.

100748

For young people, however, the Internet now rivals TV as a news source. Nearly six out of 10 Americans younger than 30 said they got most of their national and international news online; the exact same percentage said TV was the main way they got their news.

Blog Blazers Book Review

Friday, January 9th, 2009

Stephane Grenier was kind enough to send me a copy of his new book Blog Blazers – 40 Top Bloggers Share Their Secrets. I’m glad he did, it’s a very enjoyable read. It’s a lot like what the Random Bits podcast offers its listeners. In fact the book interviews both Jonathan Snook and Yaro Starak which have been interviewed here before on the Random Bits podcast. You’ll also find interviews with notables like Seth Godin, Neil Patel, David Seah and 35 other top bloggers.

The books main goal is to provide you and your blog some insight into what it takes to be successful. Reminding you that “A new blog comes online every 1.4 seconds” it sure doesn’t hurt to learn from some of the most successful bloggers to date.

In Blog Blazers, you’ll learn the secrets of 40 top bloggers, as they all weigh in on such questions as:

– What’s your best tip for writing a successful blog post?
– What are your main avenues for marketing your blog?
– What was your most successful blog post ever?
– What’s the most common mistake new bloggers make?
– What turns you off most when visiting a blog?
– What’s the best way to make money from your blog?
– Which books and websites do you recommend to new bloggers?
– Which five blogs do you regularly read?
– and many more!

It’s a quick and easy read and well worth any bloggers time.

mulberry sale spyder womens jacket cheap new balance 574 mulberry outlet cheap new balance 574 arcteryx outlet mulberry sale spyder womens jacket mulberry sale spyder womens jacket mulberry outlet mulberry outlet new balance 574

Popular Articles

Top 10 Commentators


Subscribe to this feed! Subscribe by Email!

Random Bits Podcast

You need to download the Flash player from Adobe

Other Sites