Writings & Photography of Derek Dysart, some dude you’ve never heard of.
Random header image... Refresh for more!

Category — Programming

Styling ASP.NET Validation Controls

A little break from all the photography for a bit. Since I spent the better part of the morning trying to get around this, I figured I’d document it for future developers.

If you are using the intrinsic ASP.NET Validation controls on a Web Forms project, you’ll notice they always default to being red. While this is all fine and good since red for warnings makes sense.  What if you (or your design team) want them to be a different color?  If you look at the rendereded HTML, you’ll see it makes the text red by using inline CSS:

<span id=”ctl09_uxValidatorPostalCode” title=”Required Field” class=”scfRequired” style=”color:Red;”>*</span>

Where this becomes an issue is if you try to style this via an external stylesheet (generally a good practice):

.scfRequired {
color: #005598;
}

Since there is a color specified in the inline CSS, it will take precendent.  We could add !important to our external stylesheet, but that sort of feels like a hack.  What we really want to do is get ASP.NET to stop adding the inline style. Turns out this isn’t that hard to do.  Just add a blank ForeColor attribute to your validator:

<asp:RequiredFieldValidator ID=”uxValidatorPostalCode”
CssClass=”scfRequired”
ToolTip=”Required Field”
Text=”*”
ForeColor=”"
ControlToValidate=”uxPostalCode”
runat=”server”
ErrorMessage=”Please Enter your ZIP/Postal Code”></asp:RequiredFieldValidator>

No inline CSS colors will be output and your external stylesheet rules will apply. I’m sure this isn’t news to many, but none of the first few pages of search results seemed to point this out. This applies for all of the validation controls including the ValidationSummary control which seem to have a predisposition to red.

February 17, 2010   No Comments

WMSE Archives Fixed

image If you’re a fan of WMSE and been frustrated that you haven’t been able to download archives of you favorite shows, I’ve got good news for you, the Archives are fixed! (Said with my fingers crossed.

Ever since the launch of the new site, the station had been getting sporadic reports of errors on the archive page. None of the station staff could reproduce the error and neither could I. If you know anything about software development, it is short of impossible to fix a bug if you can’t reproduce it.

The constant stream of emails to the station told us the problem was very real. Then the school informed us they were going to be upgrading to PHP5 on the server, they setup a new environment and told us to test. Sure enough the archives didn’t work under PHP5. At least now I could reproduce a problem and I hoped solving it would solve the other problem.

Since maintaining the site is not my day job, I have do any work after my kids go to bed. I spend most of the night last Monday re-writing the page from scratch, and ultimately got it to work. I wish I could say I knew exactly what it was, but my grasp of PHP is very small. The only thing I saw out of the ordinary was a call to a Postgres database being made using some deprecated API calls. Given the actual code was several years old, I wasn’t too surprised.

Even with that fixed, I really can’t wait to get the site onto a proper CMS. The staff at the station have a ton of ideas for the site and while the new site looks great, it still isn’t flexible enough to take them where they want to go. We’ll get there eventually, but at least for now you can get at all the great shows in the archive.

February 27, 2008   1 Comment

Microsoft Giving it Away

DreamSparkBannerLooks like if you’re a student, you’re in luck, Microsoft is giving away full versions of Visual Studio, Expression Studio and Windows Server.  Interesting move, since as I’ve gotten re-involved with my alma mater, the prevalence of the xAMP stack in college circles is outstanding. 

I guess time will tell if this does Microsoft any good. Make no mistake, this is about trying to stem the tide of Computer Science/Engineering students leaving school with their head full of Java and PHP. That seemed to be a focus while I was there, and I’m sure it still is.

February 19, 2008   3 Comments

Apple Can Do No Wrong?

I don’t get this.  Apple seems to be constantly updating iTunes, which I understand they must do for various reasons including updates to fix FairPlay exploits – but why do I have to download the whole freakin’ thing each time.  I got the update this morning about iTunes 7.5, when I clicked yes, it kicked off a 61MB download.  Seriously, WTF? Every update I’ve seen has been north of 50MB. Has Apple never heard of modular code?  Complain about Microsoft all you want and how there is an endless stream of security patches. At least I don’t have to download a whole new version of the software every time.

Oh yeah, that’s right.  Apple does no wrong.

November 21, 2007   No Comments

WTF on Business Logic Layers

Alex of the Daily WTF takes a break from the humorous code samples and screen prints and summarizes exactly why I hated dealing with so-called “Enterprise Architects.”  He goes over the fallacy of putting all “business logic” in a single layer, and when doing so how it makes a system needlessly complex.  He really puts into words what I’ve felt in the past when dealing with enterprise software.  My favorite quote:

It was as if its architects were given a perfectly good hammer and gleefully replied, neat! With this hammer, we can build a tool that can pound in nails.

I’m so happy to have gotten out of the enterprise software business to get some fresh air.  I’m perfectly happy coding web sites that work.  Sure, we do have to tie into back end systems and deal with some business logic, but thankfully we are insulated from most of it.  In the end all the architects that strive so hard to wrangle all of their business logic into a single layer ultimately get exactly what they deserve – a needlessly complex piece of software that is still costly to maintain.

The Mythical Business Layer – Worse Than Failure

September 25, 2007   No Comments

Great Tool for Merging

Though there are rumors we might be moving to Team Foundation Server soon, the cold reality is that my current project is Visual SourceSafe based.  Added to the mix is the fact I’m splitting my time to some bug fixing on an older version, and some new work on the current version.  The versions are branched under SourceSafe (which I have to admit, in v8 is a lot better than I remember it in back in the v6 days) and I’m stuck having to merge some bug fixes forward.  I was using the built-in merge tool in VSS, but managed to screw things up more than once.  A teammate forwarded a link to WinMerge to me, which is a god-send.  I know I’m only scratching the surface of it, but for merging across the two projects I’m on, my productivity has gone up.

One problem with VSS is comparing what files are out-of-sync in branches.  Basically I’d look at the history of a project, find the files that changed, try and print that history (and have to formatting render that report useless), then merge each one.  With WinMerge, I tell it to compare my two working directories, it tells me which files are different, I double click on the ones that are, use the super nice interface to move changes forward, and then when I save the merged file, since its read-only, it assumes it’s under source control and prompts me to check it out from VSS.  The integration could be better with VSS (I have to manually type the VSS project path), but I’m a whole lot more productive even with this little manual step.

March 2, 2007   No Comments

ASP.NET Calendar Title Styling

The project I’m working on uses an ASP.NET calendar control for a major screen element. We hook the DayRender even and spit out some links on certain days. Our PM came to me and said we needed to make the header look better. The default settings on the calendar did not look pretty when you stretch it out to a full page. “No sweat,” I thought. I’ll just tweak some of the style tags on the control. Everything prettied up nice, except the freakin’ month text. I’d set the TitleStyle tag on the control, but nothing seemed to stick. Then I found this discussion thread via Google.

Turns out the ASP.NET Calendar control has a known bug due to where it renders all the style information for the title. IE ignores it. A quick check confirmed Firefox handled it correctly. The hack described in that forum post describes taking advantage of the fact that the header is rendered in its own table element. By setting the CssClass of the whole calendar I can then use the following CSS to tweak the title table:

.calendar TABLE TD { FONT-SIZE: large }

Caveat: This is a v1.1 project – I haven’t had the time to see if they fixed this in v2.0.

February 8, 2007   No Comments

Debugging Datasets in VS2003

I’m currently working on a ASP.NET v1.1 project using VS2003.  There are some places where VS2005′s ability to examine Datasets would have been handy so thinking, “VS2003′s been out for ages, someone must have something that’ll do this” I went looking and found DSWatch.  I was using it for a while when a co-worker asked where I’d got it.  I couldn’t remember where, so during a Google search I found the original site, but the second hit was “Goodbye DSWatch, Welcome XmlVisualizer.”  Hmmm….

It was then I discovered the XmlVisualizer plugin off of GotDotNet.  Dang is it nice.  If you still do any work in VS2003 and haven’t found this tool yet, run, don’t walk and grab this AddIn.

February 1, 2007   No Comments