Click here to Skip to main content
15,878,871 members
Articles / Web Development / HTML
Article

Web Site Extreme Makeover, Part 5 of 7

Rate me:
Please Sign up or sign in to vote.
5.00/5 (4 votes)
2 Nov 2013CPOL4 min read 15.8K   8  
Adding a little C# code-behind and more HTML

Jumping Right In (not unlike a Calaveras County Frog)

Here in part five of this installment, I continue with some necessary plumbing and extensions to the site. Based on verbiage ("Our territory includes Central California from Stockton to Madera and Sonora to Tracy.") that I found on the existing site, I changed this on the home page:

Serving the Highway 99 corridor between Modesto and Merced in California's San Joaquin Valley since 1971

...to this:

Serving Central California from Stockton to Madera and from Sonora to Tracy

Based on information on their home page, I added yet another menu item, namely:

HTML
<li><a runat="server" href="~/VGB">VGB Pool and Spa Safety Act</a></li>

...and then added that new page, and transferred the text they had on the home page onto that page.

This time, though, when adding the web form, I select Add > New Item > Web Form with Master Page, and select Site.Master (not Site.Mobile.Master).

One Small Step for Coderkind

Next I copy over the "About Us" text that is on the existing site's home page, and put it in the About page. After I do that, I notice that they mention being in business since 1971, and then say it's been 38 years. Obviously, this is a little outdated, so I change the figure to 42 years, as this is 2013.

The "right" way (better way, anyway) to do this, though, is to add some code that would subtract 1971 from the current year and display that value, so that this year it will say 42 years, next year it will say 43 years, etc. So I add this code to About.aspx.cs, above the Page_Load() event handler:

C#
private const int BUSINESS_GENESIS = 1971;
protected int yearsInBusiness = DateTime.Now.Year – BUSINESS_GENESIS;

I could have gotten away with just adding one line:

C#
protected int yearsInBusiness = DateTime.Now.Year - 1971;

...adding the year directly to the computation, but I like to follow the advice of Steve McConnell in his seminal programming book Code Complete and use constants for every number except (sometimes) 0 and 1. If you don't know why, and want to know – read the book; it's full of great advice for coders. In fact, a programmer who is not familiar with and follows the tenets of Code Complete is like a … (fill in the ellipsis dots with a fitting comparison of your own devising – I think you get the gist (no pun intended)).

Also, I changed the text within the H3 tag in About.aspx from:

... For the past 42 years we've helped thousands ...

...to:

HTML
...For the past <% =yearsInBusiness %> years we've helped thousands...

..so that 42 (or whatever the calculation ends up being) replaces the variable name. Here's what the About page looks like now:

Image 1

Functional, but pretty bland; I will definitely return to this to try to give it some pizzazz, panache, or what have you before I'm through with it. For the moment, though, I'll settle for boring but functional.

One Giant Leap of Peroration

I do the same with the VGB page, copying the text from the home page of the existing site to that new page.

I set out to do the same with the Contact page, but notice that the default contact page is already set up a little better than the others. Here's Microsoft's provided template (leaving out the first line, which is very similar to that on the other pages):

HTML
<asp:Content ID="BodyContent" 
ContentPlaceHolderID="MainContent" runat="server">
    <h2><%: Title %>.</h2>
    <h3>Your contact page.</h3>
    <address>
        One Microsoft Way<br />
        Redmond, WA 98052-6399<br />
        <abbr title="Phone">P:</abbr>
        425.555.0100
    </address>

    <address>
        <strong>Support:</strong>   
        <a href="mailto:Support@example.com">Support@example.com</a><br />
        <strong>Marketing:</strong> 
        <a href="mailto:Marketing@example.com">Marketing@example.com</a>
    </address>
</asp:Content>

So, using this as a starting point, I copy over the various parts of the existing text for Hartt's Pool Plastering, so that it ends up being:

HTML
<asp:Content ID="BodyContent" 
ContentPlaceHolderID="MainContent" runat="server">
    <h2>Contact Hartt's Pool Plastering</h2>
    <h3>Request More Information</h3>
    <p>Use this link to contact our Sales Department to get more information about our company, 
    products, or services.</p>
    <address>
        Hartt's Pool Plastering & Construction<br />
        Turlock, CA 95380<br />
        <abbr title="Phone">P:</abbr>
        209.668.2550
        <abbr title="Fax">F:</abbr>
        209.664.1955
    </address>

    <aside>please <a href="mailto:sales@replaster.com">email us</a></aside>

The Contact page now looks like this:

Image 2

I've seen worse things. Still, all of these pages (About, VGB, and Contact) need some work to make them more visually appealing, but the "gingerbread" will wait until the end.

I change the ordering of menu items to: Home Images Contact VGB Pool and Spa Safety Act About

...and remove the Testimonials page, as they don't have one.

Denouement

In the next exciting installment of this Extreme Website Makeover, I will dive into the Images page, and probably add a jQuery UI widget to that, such as a carousel, to show various images in a sort of "slide show." I will likely also subdivide them into categories with the use of a tab widget. Until then!

BTW, forgive me for using the odd and hard-to-pronounce word "peroration," but I've been reading William Safire's book Lend Me Your Ears: Great Speeches in History lately and have become inundated by and thus immune to it, as William's afire with that word.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Founder Across Time & Space
United States United States
I am in the process of morphing from a software developer into a portrayer of Mark Twain. My monologue (or one-man play, entitled "The Adventures of Mark Twain: As Told By Himself" and set in 1896) features Twain giving an overview of his life up till then. The performance includes the relating of interesting experiences and humorous anecdotes from Twain's boyhood and youth, his time as a riverboat pilot, his wild and woolly adventures in the Territory of Nevada and California, and experiences as a writer and world traveler, including recollections of meetings with many of the famous and powerful of the 19th century - royalty, business magnates, fellow authors, as well as intimate glimpses into his home life (his parents, siblings, wife, and children).

Peripatetic and picaresque, I have lived in eight states; specifically, besides my native California (where I was born and where I now again reside) in chronological order: New York, Montana, Alaska, Oklahoma, Wisconsin, Idaho, and Missouri.

I am also a writer of both fiction (for which I use a nom de plume, "Blackbird Crow Raven", as a nod to my Native American heritage - I am "½ Cowboy, ½ Indian") and nonfiction, including a two-volume social and cultural history of the U.S. which covers important events from 1620-2006: http://www.lulu.com/spotlight/blackbirdcraven

Comments and Discussions

 
-- There are no messages in this forum --