The Two Rules of Web Development

by Justin 26. July 2008 16:04

As far as I'm concerned, there are only two rules when it comes to developing for the web.

  1. Do NOT use Comic Sans
  2. Do NOT use the <center> tag 
Everything else is open to debate.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Firefox World Record and IMSLP Returns!

by Justin 3. July 2008 01:23

First, champions of public domain rejoice! IMSLP (International Music Score Library Project) is back online! It was shut down last year when Universal Edition threatened to sue the site for copyright infridgement. Of course, if you don't know, IMSLP only contains scores that are in the public domain. That means free and legal. So most of the works you'll see there are PDF scans of very old sheet music. However, that doesn't sit well with companies that make good money off of long dead composers. So they used lawyers to intimidate the college student behind IMSLP, who does not have the means to legally protect himself. Thankfully, many people got behind the kid and offered support, including some prominent university legal experts. Regardless, it's back online!

Second, Firefox indeed set the Guiness World Record for Most Downloads in a 24-hour time frame. According to Spread Firefox: "We set a Guinness World Record for the most software downloads in 24 hours. With your help we reached 8,002,530 downloads."

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Uber Geeky

by Justin 26. June 2008 00:20

I'm a professional computer programmer with a degree in Computer Science. Needless to say, I've seen some pretty geeky things done by some pretty geeky people, but nothing tops what a co-worker showed me the other day.

If you telnet to towel.blinkenlights.nl then you'll see an entire scene-by-scene recreation of the first (er, fourth) Star Wars movie done in ASCII!

  1. In Windows go to Start > Run..., or hold down the windows key and press R. 
  2. Type "telnet towel.blinkenlights.nl", without the quotes.
  3. Marvel.



Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Firefox 3.0 To Be Released 6/17/2008

by Justin 14. June 2008 12:09
Version 3.0 of Firefox will officially be released to the public on June 17th, 2008. You will be able to download it from http://www.spreadfirefox.com/en-US/worldrecord. You can view the release notes at http://www.mozilla.com/en-US/firefox/3.0/releasenotes/.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Using the HTML label element with ASP.NET

by Justin 1. May 2008 00:28

You've probably noticed that a <asp:Label /> element actually renders a <span> tag, not the <label for="name"> tag that's been around since HTML 4. Luckily, it's pretty easy to include the label element in your ASP.NET forms.

ASP.NET 2.0, 3.0, 3.5 and Later

To make the <asp:Label /> control render as a <label> instead of a <span> include the AssociatedControlID attribute like so.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
	<title>Untitled Page</title>
</head>
<body>
	<form id="form1" runat="server">
		<asp:Label ID="Label1" runat="server" AssociatedControlID="TextBox1" Text="Label"></asp:Label>
		<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
	</form>
</body>
</html>

 

ASP.NET 1.0, 1.1

Unfortunately, older versions of ASP.NET don't support the AssociatedControlID attribute. Instead, you'll have to create a regular HTML <label> element and manually write out the ID of the associated control in the "for" attribute. 

<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="test.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
	<title>WebForm1</title>
	<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
	<meta name="CODE_LANGUAGE" Content="C#">
	<meta name="vs_defaultClientScript" content="JavaScript">
	<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
	<form id="Form1" method="post" runat="server">
		<label for="<%=TextBox1.ClientID %>">Label</label>
		<asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
	</form>
</body>
</HTML>

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Decompile a .NET DLL into a Visual Studio project

by Justin 26. April 2008 09:34

As a professional developer you will eventually have to view or edit some code that you do not have the original source to. The original source could've been lost, accidently deleted, or never given to you when it should've been. When you are in one of these situations try the following.

  1. Download Reflector, which allows you to open an assembly (i.e. DLL file) and view its contents. However, by default you can not modify or export the contents of the DLL. You will need Add-Ins to do that.
  2. Extract Reflector into a directory on your computer. I chose C:\Program Files\Reflector\ as my directory.
  3. Download the File Disassembler Add-In, which allows you to export the contents of the assembly into a Visual Studio project.
  4. Extract Reflector.FileDisassembler.dll from the zip and into to the same directory as your Reflector application.
  5. Open the Reflector application.
  6. Chose whichever version of .NET that you're currently using.
  7. Go to View > Add-Ins and click the Add... button.
  8. Double click Reflector.FileDisassembler.dll to selected it, then click Close.
  9. On Reflector's menu bar under Tools there's now an option called File Disassembler.
  10. Use File > Open to open the name of the assembly that you want to decompile. It will load in the left pane after the Microsoft assemblies.
  11. Click on the assembly's name once to select it.
  12. Go to Tools > File Disassembler to open up the file disassembler's pane. Tip: Close any other pane's that may be obstructing your view.
  13. Make sure you're okay with the Output Directory and you have your language of choice selected in Reflector. (i.e. C#, Visual Basic, etc.)
  14. Click the Generate button in the File Disassembler pane.
  15. Navigate to the directory that the DLL was decompiled to and enjoy!

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , ,

How to Run WebKit On Windows

by Justin 25. April 2008 02:05

So I've been noticing a buzz in the web dev community lately about a web browser called "WebKit. " It made some news recently when it tied with Opera as being one of the first browsers to pass the Acid 3 test.

Don't get too excited, it's just an open source version of Safari. Well, it's the rendering engine that Safari is built off of, which is apparently based on the same engine that's used by Konqueror. (Now there's a browser we haven't heard of in a while.) It seems that in order to "install" WebKit you basically have to run a script that uses an existing Safari install as its user interface. The install seems to be temporary.

Running Web Kit

  1. If you don't already have it installed, then download Safari and install it.
  2. After it's installed check out the Acid 3 test, and you'll see that Safari fails it (as of 4/24/2008).
  3. Download the latest build of WebKit.
  4. Extract the zip to your desktop.
  5. Double click the run-nightly-webkit.cmd script. The old MS-DOS console will open and will spit out a series of file updates.
  6. Safari will automatically launch, and even though it says it's Safari it's actually WebKit. Navigate to the Acid 3 test and you'll see that it passes it. Note that your original Safari install is unaffected.
 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

Add a Fade Effect to Your Forms

by Justin 6. April 2008 00:08

Forms are boring! Or are they? Make any form more interesting by morphing between your form's questions using mootools, a JavaScript framework. Just click the first link below and click "Next Question >>" to see the effect in action. Then click the second link to see what the page would look like if the user had JavaScript disabled.

Demo with JavaScript Enabled

Demo with JavaScript Disabled (Simulated)

Not only can this be used with a form, but with anything that you want to break up into steps, such as a wizard that guides the user through a list of new features for a product.

The technique I use is known as unobtrusive JavaScript, which means the page does not rely on the JavaScript to work. Rather, enabling JavaScript will result in some "bells and whistles," but if it's turned off the page is still 100% functional. My goal was to keep this script as simple as possible, so feel free to edit it and use it on any of your projects—free of charge or limitation.

The script basically works like this:

  1. Get all the questions, or steps, in the form.
  2. Dynamically add some navigation controls to move forward and backward for each question.
  3. Hide all the questions or steps, except for the first step.


Whenever a link is clicked an event is called to handle which step is faded in as the current step is faded out.

Download mootools script
Download fade effect script 

Note: Everything in the "options" section of the class is there to allow you to easily customize the script. The "initalize" section is basically a constructor for the class itself.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , ,

Internet Explorer 8 Beta 1 is Here!

by Justin 6. March 2008 01:14

Download IE8 Beta 1!

Perhaps the most incredible news came Monday when it was announced that the default rendering mode for IE8 will NOT be the legacy engine, but the web standards engine. This is great news for those of us who want the web to move toward interoperability.

I'll be honest, I didn't believe Microsoft when they claimed that web standards was going to be the default rendering mode. (I mean, I just watched a video a few weeks ago about how Microsoft doesn't want to break backward compatiblity.) So I installed IE8 Beta 1 and went straight to the Acid 2 test—and to my surprise it worked.

Internet Explorer 8 Beta 1 passes the Acid 2.. by default!

Now the new meta tag I mentioned has not been disgarded. Rather than rendering with the old engine by default, and using the meta tag to force "standards mode," Microsoft has opted to render in "standards mode" by default and using the meta tag to force IE8 to use the old rendering engine. In other words, if your site breaks in IE8 you'll need to add the new meta tag to it, or upgrade your site to follow web standards.

Needless to say, I could not be happier with their decision. If IE8 launches to the public as expected, then web standards should finally be the standard within a few years of the release date.

Developer Tools

The new "Developer Tools" seem to be a fusion of Microsoft's Internet Explorer Developer Toolbar and Firebug. One of the first things I noticed after installing IE8 was that the Developer Toolbar no longer works because it's been replaced by Developer Tools. It's a shame because there are many useful features of the Developer Toolbar that are currently absent from the new Developer Tools. If you need the toolbar to do your job then I'd recommend not installing IE8 Beta 1 until the Developer Tools have matured.

Anyone who's familiar with Firebugs' CSS tracing capabilities will probably be disappointed with the Beta 1 offering from Developer Tools. Unlike Firebug and the Developer Toolbar, you can not manipulate CSS on the fly. However, I liked Microsoft's new JavaScript debugger better than Firebug's debugger. What's been missing until now is a good, free JavaScript debugger for IE that's quick to open and easy to use. If you're familiar with Visual Studio's debugger you'll have no trouble figuring out the new JavaScript debugger. I was using it within seconds, whereas Firebug had took some experimenting to get used to.

For more information on IE8 check out the new Internet Explorer 8 Readiness Toolkit.

Conclusion 

If you're a web developer IE8 is definately something to be excited about. However, I uninstalled IE8 and went back to using IE7, the Web Developer Toolbar, and MultipleIEs. The lack of CSS manipulation capabilities in IE8 was disrupting the speed of a project that I am working on. Hopefully, Beta 2 will have better CSS support in the Developer Tools.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

The Ternary Operator (My Guilty Pleasure!)

by Justin 28. February 2008 11:37

Most of the time I am "Mr. Best Practice," but I have one flaw—I think the conditional ternary operator is great! Yes, we've heard it before—they are "hard to read" or "they are error prone," but I disagree. If you understand how it works, and you don't over-complicate your syntax, it's not hard to read or error prone at all. In fact, I believe if used correctly it can increase readibility by decreasing code clutter.

What is it? The conditional ternary operator is simply a conditional operator that accepts three operands. It takes a condition, and then depending on that condition returns one of two operands. Here I demonstrate the basic syntax..

variable = condition ? true part : false part;

Here are a few examples that may be easier to grasp..

int i = true ? 0 : 1; // i = 0
int j = false ? 0: 1; // j = 1

 

The ternary statement is basically just a short-hand way of writing five lines of code..

int i; // i = 0
if (true)
    i = 0; 
else
    i = 1; 

 

Do you use VB.NET? Just use the IIf function instead. The following two lines are in different languages (C# and VB.NET, respectively) but they produce the same result.

int i = true ? 1 : 2; // i = 1
Dim i as Integer = IIf(true,  1, 2) ' i = 1

 

Now the problem with the ternary operator is that people sometimes get crazy with it. You can embed a ternary statement inside of another ternary statement, just like you can embed an if inside of another if..

int k = true ? false ? 2 : 5 : 1; // k = 5

 

.. which is the same as ..

int k = true ? (false ? 2 : 5) : 1;

 

.. which is the same as ..

int k;
if (true)
{
	if (false)
		i = 2;
	else
		i = 5; 
}
else
	i = 1;

 

It doesn't stop there, you can put anything inside a ternary that's considered in-line code. That is, anything that doesn't require a line break. Here's a little exercise for you. Work it out in your head, then compile it to see what the answer is. (Of course, you'd never want to do anything like this in a real project!)

bool a = true, b = false, c = true;
bool d = a || b ? c && b ? a || c : b  && c : a || c ? b || c : a && b;

 

As you can see, conditional statements that use the ternary operator can quickly get out of hand, but as long as you don't get crazy they should still be readable. If they're not readable, or readability is questionable, then you should use the classic if/else block instead.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen