Donnie

Donnie

(29 comments, 42 posts)

A web developer, musician and overall regular guy living the dream in blissful Birmingham, Alabama.

Home page: http://www.finalint.com

Yahoo Messenger: dgarvich

Jabber/GTalk: dgarvich

AIM: dgarvich33

Posts by Donnie

Making jQuery and ASP.NET AJAX Play Well Together

0

This one caused me a few headaches tonight, so I figured I could throw something on the blog in the hopes that Google would lead someone to what turned out to be a less than logical solution, but a solution. ;)

First, the setup:  Basically, I have a page that was written by someone else and that person had an affinity for the Microsoft ASP AJAX Control Toolkit (I have no idea why).  Well me, I have an affinity for jQuery.  So I set about building new functionality on the existing page in jQuery, while trying to keep the functionality that was already there untouched and in tact.  That turned out to be more difficult than expected.

I’m sure there are tons of issues to work through on this and I may update this article as those arise.  But first up I had to figure out why the standard jQuery $(document).ready() functionality wasn’t working when there was, most obviously, a PostBack occurring.  And, as it turns out, there’s a sort of fake PostBack that occurs when using the AJAX.NET toolkit.  Lame.  But here’s how to handle it (full code description follows):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
    <script src="scripts/jquery-1.4.2.min.js" type="text/javascript"></script>
    <script type="text/javascript">
		$(document).ready(function() {
			EndRequestHandler();
		});
 
		function load() {
			Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
		}
 
		function EndRequestHandler() {
			// do page load things
		}
    </script>
</head>
<body onload="load()">
    <form id="form1" runat="server">
    <div>
 
    </div>
    </form>
</body>
</html>

The Breakdown

First, you need to create a client side (JavaScript) function to execute whenever a page is “loaded” (I put it in quotes because the load event sometimes fires and sometimes doesn’t when using AJAX.NET).  You need the two layers of abstraction here so the function can be called in the multiple scenarios that are created by a real page load and an AJAX.NET partial page load:

1
2
3
function EndRequestHandler() {
	// do page load things
}

Now, once you have created that function you need to call it from both the jQuery and ASP.NET client side load events.

First up, the standard jQuery call will work pretty much as expected:

1
2
3
$(document).ready(function() {
	EndRequestHandler();
});

The ASP.NET version requires that you make another function and attach the first function to the client event… Yeah, I know, it’s wonky.

1
2
3
function load() {
	Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
}

Once you’ve done all the jumping through flaming hoops, you can just attach the function to the body tag’s onload event and everything will be wired up and ready to go.

1
<body onload="load()">

Enjoy!

How To Have Multiple Domains Using 1&1

5

If you read my other post, you know about the problems I have had getting a client set up with multiple domains hosted under the same 1&1 account. 1&1′s decision to market their hosting as “have as many domains as you want” is misleading at best, because they require that each domain point to the same place. You have to handle ALL multiple domain requests using a coded solution. This isn’t ideal for far too many reasons to list here, but I figured I could offer someone some help if they are running into the same problem.

Pre-Conditions

  1. First you have to have all of your files set up correctly.  The correct way is to have a sub-directory for each site that you want to host under the account.  You may have better luck, but I couldn’t get directory names with dots in them to work (just another thing on the long list).
  2. Once you have your files set up, you need to make sure that each site’s domain is pointed to the account root.  Not the sub-directory that you have created for the site.

Primary Redirect File

Now, in the account root directory, you need a file called default.asp that will include code similar to the following:

1
2
3
4
5
6
7
8
9
<%EnableSessionState=False
  host = Request.ServerVariables("HTTP_HOST")
 
  if host = "domain1.com" or host = "www.domain1.com" then
    response.redirect("http://domain1.com/domain1-directory/default.aspx")
  elseif host = "domain2.com" or host = "www.domain2.com" then
    response.redirect("http://domain2.com/domain2-directory/index.shtml")
  end if
%>
Your sites will now technically work.  But wait, there’s more!  What if you want to have custom error pages for each site?

Custom Error Pages

Of course, there’s more hoops to jump through.  This can’t be done on the server side because the default IIS error files are .html files.  So you basically have to fool IIS into using your files by naming them the name that IIS uses by default.  Then, you have to use code similar to the following to make sure sites redirect whenever an error page is hit.  Yes, I know this isn’t ideal, but the entire account is now a hack because 1&1 sucks, so I’ll live with it until I convince everyone to abandon 1&1.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
		<title>Error!</title>
		<script type="text/javascript">
			if (location.hostname == "domain1.com" || location.hostname == "www.domain1.com") {
				window.location = "http://www.domain1.com/domain1-directory/404.shtml";
			} else if (location.hostname == "domain2.com" || location.hostname == "www.domain2.com") {
				window.location = "http://domain2.com/domain2-directory/error404.html";
			}
		</script>
	</head>
	<body>
	</body>
</html>

After All…

While my preference would be to never have to deal with this crazy hack-happy format for having an account with multiple domains, I will undoubtedly run into this again.  Who knows, maybe someday you will to and this article will prove helpful.  I guess, in the end our world is all about hacking solutions into place, right?  ;)

1&1 Hosting – Your Tech Support Sucks!

2

I’m frustrated.  I just spent nearly half a day setting up a site for a client to get ready to “go live” soon.  Setting up the site on their already existing, shared hosting account with 1&1 Hosting was part of the final round of things to make sure we were good to go.

Here’s the situation.  The client has two domains hosted on this account (1&1 promises you can have as many as you want).  The new site I’m putting up will replace one of the existing sites when the client is ready to pull the trigger.  So my approach was to set up the site in a new directory and create a “dev”.theirdomain.com sub-domain to point to it.  This is pretty standard practice and it allows me to check the site on the server it will eventually live on instead of just throwing code at an unfamiliar server and crossing my fingers.

So I used their handy-dandy control panel to create the sub-domain and point it to the new directory.  Then I pushed all of the files to the new directory via FTP.  All of the *.shtml files worked, but any time I tried to call a *.aspx file I would get a 404 error.  Odd… I know they’re there…  So I spent an hour or so poking around their control panel looking for something I may have missed.  Oh, there’s a way to create an “application” out of a directory but you can only have 5 of them.  Surely that’s it.  Nope.

So, defeated, I caved and decided my last heroic productive act of the day would be to call their tech support.  After a short wait, I get “Jean” (pronounced like Shohn) on the phone.

Me:  Hey Jean, I’m trying to get a sub-domain set up so I can run some .NET files.  Everything seems to be working, I can access any of the .shtml files but none of the .aspx files work.  I get a 404 error!

Jean:  You need to make redirect scripts on your main domain.

Me:  Well… that would take down the pages on the main domain and I really don’t want the client’s live site to go offline.

Jean:  (le sigh) It will work, you need to create redirect scripts on the main domain.

Me:  I understand that creating redirect scripts will work to forward traffic to this new site.  But are you telling me that for every aspx page I have on the new site I have to create a redirect on the old site to forward it over?

Jean:  Yes

Me:  That can’t be right.  Maybe I misstated my original question.  Let me try again.  I have created a sub-domain and pointed it to a directory at the same level as the other site.  Everything is running on it just fine, except for any page that is a .aspx page.  All .aspx pages give a 404 error whenever I try to access them, which isn’t good because the default page is… well… Default.aspx.

Jean:  (aggressively) You should create redirect scripts on your main domain.

Me:  Yeah thanks, bye. *click*

Seriously guys.  Your tech support sucks.  I’m going to try again tomorrow, but if the answer truly is that you are unable to enable .NET for sub-domains then your hosting service sucks too.

Google To IE6, “Die already!”

0

I’m a big, big fan of Google Apps.  Their decision to allow people to piggyback on their services with their domains was nothing short of brilliant.  Every domain I have set up since has used their service and I have nothing but good things to say about it.

Friday they gave me another reason to love them by sending me an e-mail informing me that:

In order to continue to improve our products and deliver more sophisticated features and performance, we are harnessing some of the latest improvements in web browser technology.  This includes faster JavaScript processing and new standards like HTML5.  As a result, over the course of 2010, we will be phasing out support for Microsoft Internet Explorer 6.0 as well as other older browsers that are not supported by their own manufacturers.

We plan to begin phasing out support of these older browsers on the Google Docs suite and the Google Sites editor on March 1, 2010.  After that point, certain functionality within these applications may have higher latency and may not work correctly in these older browsers. Later in 2010, we will start to phase out support for these browsers for Google Mail and Google Calendar.

For those who need a translation:

We at Google, after careful observation of the Analytics trends for our Google Apps usage, have noticed a single defining characteristic shared by 100% of our problem users.  This characteristic is an affinity for Internet Explorer 6.  Therefore, in an attempt to rid ourselves of as many idiots as possible, we are dropping support for their favorite software.  Stop using Internet Explorer 6 or stop using Google, we don’t care which.

This is a bold move by Google, although completely necessary (and inevitable) if they want to make the best applications the web has to offer.  And honestly, I wish more companies would take this stance.  But on the heels of telling China to shove it I’d say Google may have decided that they are now well established enough in both the political and technical arenas to start throwing some weight around.

I generally don’t like when big companies start using their size to dictate trends, but when I think about it that’s probably because almost always the big company does this to further their agenda.  Rarely does my agenda fall in line with theirs.  From a technology standpoint, Microsoft is the most frequent offender on this front, and we all know that when Microsoft throws its weight around it’s in an effort to make more people see things Microsoft’s way, not in an effort to make the world see things the agreed upon standards way. At least so far, Google seems to be forwarding web standards which are something that for better or worse we as a technical community have agreed upon as good.

I, for one, welcome our new Google overlords…  As long as those overlords hate IE6 as much as I do.

Trillian 4.1 – One Giant Twitterific Leap

0

I’ve been using Trillian Pro for years.  It has always made managing the various chat mediums I have to stay contacted much easier and that makes my life better, so I’m willing to pay for the app.  Now, though, with the introduction of Trillian Astra, the team over at Trillian seems to be honing in more and more on what exactly I want to have as an every day social power user.  The newest release, Trillian 4.1 (released today) is no exception, catching me a little off guard with some of the great options it has provided me with.

In addition to using every available chat medium to stay in touch with different groups of people, I use Twitter… a lot.  I have several accounts for several different reasons and they all have unique needs.  In the past these unique needs have made me do a lot of juggling to be able to manage everything.

No more, thanks to Trillian’s new release of Astra.  I mean, the client has all of the basics that you would expect, but in addition to those basics are the following reasons that Trillian Astra is now my favorite Windows based desktop Twitter client:

Multiple bit.ly Account Support

Sure, lots of clients allow you to manage multiple Twitter accounts.  I’ve been using TweetDeck with decent success on that front for some time.  Then there are some clients which actually allow you to integrate with your bit.ly account, so that when the Twitter client automatically shortens a link for you the link is added to your bit.ly account so you can track it like you would any other.  But what about clients that let you manage multiple Twitter accounts which are each attached to their own unique bit.ly accounts?  Is it really that mind-boggling that this would be something a power user would want?  Who knows, but Trillian Astra got it right.  Add your Twitter account then right click on the account in your contact list, click settings and WHAM-O you’re ready to enter your bit.ly API key and go to town.

Intelligent Character Limitation Counting

Something else that other clients should get on the ball with is knowing how many characters things like image uploads to TwitPic are going to take.  No more wondering, biting your nails and hoping that your image upload URL doesn’t throw your character count over by one character, ending your perfect digital planetary alignment.

Tweet Screenshots

This one is really nice for technical tweets / blogs / etc.  Basically, you can use any image in your tweet via TwitPic by dragging it into your message.  But if you right click in your message, you have the ability to actually trim out a screenshot to use.  Nifty!

Side Docking

I don’t check news sites any more.  I don’t check my favorite band sites any more.  I don’t have to, because I have a constant stream of updates that interest me flowing through Twitter.  Now, thanks to Trillian’s function of docking to the side of your monitor (reserving space so that maximized windows don’t overlap it), something they’ve had for a long time, that stream is constantly available at a literal glance to my left.

There are, of course, still a few issues that exist (when you open a retweet you have to type / delete a character for the character counter to register) and some functionality I’d love to see added, but nothing that overrides how awesome the new Trillian is at managing my fairly advanced Twitter needs.

Notification Placement

This isn’t a Twitter specific update, nor is it unique to Trillian.  But the ability to place your notification popups where you want them, even with multiple monitor support, means they don’t get in the way of something else that you were trying to do.  It’s a really nice touch that makes a big difference to me.

Nice job guys!  Now, about that post I made on your forums asking for the ability to have a transparent background with fully visible text…

Windows 7 Boots Slow – Check Your Wallpaper!

0

Let me start by saying I have a monster of a machine.  I use it for more demanding tasks than most people will ever ask their computer to do and it performs all of them admirably and quickly, all in 64-bit glory.  Then, I upgraded to Windows 7.

Now, at first, things were unbelievable and I was in love.  And truth be told, they still are and I still am, except during the boot sequence.  Whenever I boot, the OS takes forever to load.  It literally just sits, no disk activity, no notable processing, no informative messages on the screen, nothing.  And then, all of a sudden, everything loads almost instantly.  It’s almost as if there was an intentional delay or something.  Suspicious, right?

So I started researching this today.  I’m not exactly sure why it surprises me but apparently there is a bug in Windows 7 that causes a 30 second delay during boot if you use a solid color as your wallpaper.  Silly me and my minimalist approach looking for better performance.  I thought not loading a wallpaper would be easier for the machine to do than loading one.

I found the original article over on Lifehacker.  Within that article they provide links to a hot fix and some workarounds.  But I figured creating another article couldn’t hurt, just so people would know what was up.

Trillian Astra – The Dark Side (of skins)

0

I don’t have enough time to make a short post here, so I’ll likely be leaving a long, rambling one.  You’ve been warned.  ;)

I’m a Trillian user.  I love it.  I bought it, I will continue to give them money as long as their product continues to meet my need of having EVERY chat network known to man connected at the same time.  I know my IRC pals laugh at me for using Trillian, but whatever.

There were a couple of things I wasn’t crazy about in Trillian Astra, however.  The primary being that the default skin was bulky, and the included secondary, minimalist skin (Cobalt) didn’t contain any dark themes.  I’m sorry, but using a white background on chat windows just makes me feel, as a friend said, “flashbanged” every time I chat.

Surprisingly, there aren’t that many good skins out yet using the new features provided by Astra.  There are a few, however, if you can figure out where to look.  So I’m going to make that easier here and provide a collection of links to resources I used to get what amounts to a dark version of Cobalt.

Listing: A list of Astra Skins, Plug-ins and Mods
Skins: Cobalt Black Magick (Fixed) | Avion Pro

There, maybe I’ll come back later and write up how to disable specific sounds without losing the ones you want.

###

Update – 01.20.2010 – A new Trillian build was released today that improved, among other things, Trillian’s support for Twitter.  This could change the way I use Twitter, moving me away from TweetDeck.  However, the skin I had been using (Cobalt Black Magick) doesn’t yet support the new character counter functionality.  So I’ve added a link to the other skin I love from the list, Avion Pro. – DG

iPhone Can’t Find Wifi, Oh No!

2

Tonight I spent some quality time uncovering a bit of information I couldn’t find referenced anywhere else on the web. Not that this solution hasn’t already been written somewhere else, but among the many, many discussions about why an iPhone can’t access ANY wifi networks (apparently there are some hardware AND software issues with some iPhones) it was impossible to find what I needed.

First, the situation.

We have a working wifi network that was set up by someone else. We know it’s working because there are two laptops successfully connected. The network has no security enabled and is set up in combination mode (n/g/b). The router is made by Belkin.

We have three iPhones, all of which spend a great deal of time connected to wifi, none of which can access this network.

Now the solution. Remove spaces from the network name in the router settings. No, seriously… Go do it, it works.

Apparently our laptops (XP and Vista) had no problems working with the spaces, but the iPhones just weren’t getting it done. Hopefully this helps someone in the future, but to summarize: iPhones do not recognize wireless networks with spaces in their names.

TweetDeck – Making Twitter (more) Useful

0

I can’t help it, I like Twitter.  I love the format of communication it provides.  People don’t have to know who you are for you to get their updates… and you don’t have to know who someone is for them to get your updates.  That makes for some really interesting possibilities.  Additionally, since the media blitz surrounding Twitter has continued to build, more and more “service” type of accounts have popped up which actually provide useful, timely information in a quasi-push format.

In general I’ve used pretty standard Twitter clients.  Ones which were obviously based around what the standard Twitter web site provided as an interface.  It’s a basic approach which just shows all the tweets that have come from all of your friends since you last took a look at it.  I’m not particularly unhappy with the clients I’ve been using (in particular Twittelator Pro is good) but a month or so ago I decided to look around and see what was out there.  Enter TweetDeck.

TweetDeck, right from the get-go, is different.  It offers columns, which are basically different views of your Twitter information arranged… in columns.  These columns can be built however you want to build them, which is where I have found my new best Twitter tool friend.

By default TweetDeck offers what you would probably consider pretty standard columns, “All Friends”, “Mentions” and “Direct Messages.”  For a while, I depended on these and while they were cool, they didn’t offer much functionality that I didn’t already have elsewhere.

Then I got the bright idea to start using the columns to separate information.  “What if I didn’t have an ‘All Friends’ column at all?”  Well, it turns out that’s a great thing…

So I set about making a column for “Friends and Family” which included… er… all of my friends and family.  Then I made a column for my “Professional” folks.  I kept the mentions and direct messages columns.  And here’s where it gets fun, I made a column for “Celebs and Bands” (I follow a lot of bands and band members) and one for “Services.”  The “Services” column is where I did some things that were new to me…  I followed several of my favorite news services and added them to this column.  Now, I can use Twitter to keep up to date with my friends, post ideas / discussions and now… dun dun dun… keep up with news!

Further, what’s really, really cool is that TweetDeck allows you to create a TweetDeck account and save the columns you have created.  Once you save them, you can sync your columns anywhere you use TweetDeck (it works on Windows, Linux, Mac [all using Adobe Air] and the iPhone).  This is great for me since I use several operating systems as well as the iPhone.  This made things really easy and I’ve found myself using Twitter more and more.

Google Chrome Launches

0

While it is admittedly early to be talking about a full-blown review, I’d like to at least take a moment to discuss one of the most significant browser releases in recent history.

As someone who has spent the last 13 years writing web applications I’ve seen first hand the path modern browsers have taken to get to where they are.  Knowing what I know about this path, I can also say that the journey has been a long one full of good intentions and without much concern for developers (or standards).  That’s why I’m so impressed with what Google is doing here.

Apparently Google “accidentally” sent a notification about their browser intentions a day early, resulting in a frenzy around their creative and informative announcement “comic.”

Then, today, they officially released the browser that was the source of all of the discussion.  With their claims of speed, performance and standards compliance I was skeptical.  After all, like I said I’ve been fed the “we made it faster” line a thousand times over the past 13 years and I’ve almost never been impressed.  Sure, you can benchmark browsers and prove a 3% increase in speed but what does that buy me in the real world?

When we’re talking about Chrome, however, we’re talking about insanely fast.  Let me be clear, I’ve developed a LOT of applications for intranet usage (internal company networks) and I can say that the “slowness” often felt while using web pages is not a result of bandwidth limitations or slow downloading.  Instead, it is a latency experienced while the inefficient browser engines parse through the code needed to create a web page.  This is even more obvious when the page has complex (read:  useful) JavaScript in place.  All that is to say, Chrome is so fast it does away with the expectations you have about using web pages.

I’ve read where some folks had problems with pages, but I’ve looked at all of the ones I am responsible for and found no issues whatsoever.  This is probably because I test them in Safari, which uses the same engine for rendering as Chrome.

So for now, those are my thoughts.  I’ll post more here if things go insanely awry, but I plan to use Chrome as my primary browser at home for a while to see what I run into.  Oh… and I posted this using Chrome on WordPress, so we know that works!

More Chrome Information:  http://tools.google.com/chrome/intl/en/features.html

Download Chrome:  http://tools.google.com/chrome/

Donnie's RSS Feed
Go to Top