This Damn Thing Should Work

Monday, October 24, 2005

Mouseovers with an Hyperlink object

Another nifty little technique - when using ImageURLs with the Asp.NET hyperlink object, in order to do rollovers you need to do something like this:

OnMouseOver="this.firstChild.src='/images/rollover.gif'"

Works like a charm...

Wednesday, June 22, 2005

ASP.NET Date Formatting

It never fails - everytime I want to format a date any way other than the standard MM/DD/YYYY, I always have to look it up. I guess it's infrequent enough that it doesn't stick in my brain - I have no idea why I can remember obscure IP Addresses and Family Guy lines but I can't remember these...

This is a decent resource for this stuff - doubt it's exhaustive but its been good enough for me...

ASP.NET Data Web Controls Kick Start - Companion Web Site

This one is a little more complete - sans examples though:

http://www.riderdesign.com/articles/displayarticle.aspx?articleid=5

Tuesday, June 21, 2005

Hanselman's List

This appears to be an excellent list of tools for developers...

ComputerZen.com - Scott Hanselman's Weblog - Scott Hanselman's 2005 Ultimate Developer and Power Users Tool List

Monday, June 20, 2005

ASP.NET and HTML/Plaintext Emails

Here's the issue - we built a mass emailer (I know I know - contributing to the problem, blah blah) that we hooked up to a WYSIWYG HTML editor. Client generates her newsletters every month and sends em out.

I'm using ASP.NET, so I use the System.Web.Mail namespace and the MailMessage object to send out the emails, formatted in HTML. Everything works fine in testing, and we're all happy.

Then a few reports trickle in (along with example emails) of the text of the newsletter with all the text glommed together. I gathered from the people reporting this that they were using plaintext email readers. Basically the tags were being stripped and the email was sent out with what was left (which was a big glob of text).

My first reaction was surprise - I remember the days of plaintext email readers and getting an HTML formatted message usually consisted of the "this message is of Content-Type HTML" etc. that displayed a not so great looking version of the email - but you knew it was HTML and that was the issue. These messages were different - they looked like normal email plaintext messages - but they were coming from an HTML formatted message.

After a sizable amount of digging, I found out that the System.Web.Mail namespace automatically creates a plaintext version of HTML formatted messages and delivers the email as "multipart/alternative" which allows the plaintext readers to ignore the HTML version. This was a footnote on a website somewhere - couldn't find any reference to it on Microsoft's site...

After some more testing, I found out that our WYSIWYG was generating its break tags as <br/> rather than <br /> . I did a batch replace before sending the email and suddenly everything worked fine.

Sigh...

Friday, June 17, 2005

ASP.NET, Javascript, and Server Controls

I've mentioned before that I'm a Javascript junkie - I find myself using it quite a bit. ASP.NET made it a little tougher in the sense that when using server controls, the id assigned to the control varies depending on the situation. In a normal situation, the id assigned is used. But when used in a user control, the name of the user control is appended to the beginning of the id. As long as you understand these rules, its possible to get it all to work.

Today I found this - which looks like it takes some of the guesswork out by using the ClientId attribute of a server control...

Accessing Server Controls Using JavaScript

Wednesday, June 08, 2005

Unicode and ScrollKeeper

Another nagging issue solved - although it reintroduces a previously solved nagging issue - sigh.

A few months ago, I was getting complaints from clients that had lengthy forms that when I used an autopostback from a dropdownlist the screen would return to the top of the form rather than where they were. Some digging quickly showed that this was a known ASP.NET issue, and there were a few ways around it, all hacks. Microsoft gave their own version with SmartNav, but all the discussion said it sucked, so I looked around and found an article (http://philiprieck.com/blog/archive/2004/02/11/ScrollKeeper.aspx) that I tried and it solved the issue. I was impressed because it was really easy to use.

Fast forward a few months. I've used the Scrollkeeper code in a number of projects and have had no problems with it. But with this one site we just launched, everytime you posted something with Unicode characters in it, it lost the unicode and replaced it with a ?. I tried EVERYTHING I could find on encoding issues with ASP.NET, the editor we were using, anything and everything. Probably spent close to 10 hours trying to solve it. Finally, today, I figured out that it was the ScrollKeeper code that was causing the issue. As soon as I took it out everything worked fine.

You might be wondering why I didn't try that earlier. The answer is that basically it has always worked before.

Cripes...

Friday, June 03, 2005

JavaScript Strings

This is a pretty useful resource for people playing with strings in Javascript...

IE 6.0 - JavaScript - Strings