imagine kitty magazine

Skip to main content
  • Categories

    • America
    • ASP.NET
    • Bible tags
    • C#
    • Christianity
    • Classic ASP
    • Firearms
    • Humor
    • LINQ
    • MVC
    • Programming
    • Random
    • Trackbacks
    • Web design
    • Web standards
    • Why I am the way I am
    • Wordpress
  • Links

    • benthack
    • ASP.NET Resources
    • Bible Dude
    • Cake Wrecks
    • Church Communications Pro
    • Creating Passionate Users
    • Dossy’s Blog
    • Gary Turner’s html & css workshop
    • I Will Teach You To Be Rich
    • id Projections
    • Information Pollination
    • Pescatarian Cooking
    • SystemDotWeb
    • The Crazy Rants of Samantha Burns
    • The Nice Jewish Website
    • The Sneeze
    • Tyssen Design
  • Pages

    • Bible verse tags 2.0
    • Privacy Policy
    • Steps to building a proper web page
  • Info

    • Log in
    • contact mark
    • blogs that link here*
    • valid xhtml
    • valid css
    • valid rss2
    • rss feed
Sigarms P229

spam this

U.S.A. R.I.P.

America in distress

Regardless of the will of the people the House passed HR3590. Next step is to vote these arrogant, anti-liberty traitors out of office. Unfortunately, it will take years to undo this mess.

Posted in America by Mark (21Mar10 @ 1817)

Trackback | Permalink | 1 Comment

Open Trackback Alliance

To get your article listed below please visit this link and link up your best work.

The following articles do not necessarily represent the views of imaginekittymagazine.

  • The Trouble With Angels: Prize Game Up At "Dead Guy"...
    For those of you who aren’t regulars but may want a chance to win the prize T-shirt, you need to get on over to Dead Guy On The Sidebar and get your...
  • Cao's Blog: “He’s our brother”...
    Read this piece “Notes from a War Diary” by Ollie North. There are several little stories there, but the last one is the one that touched me the most....
  • 123beta: Please Send Money...
    Dear good person from North America, I’m an honest, hard-working Nigerian King, just waiting for my bank to release millions of dollars to me to help my family and...
  • 123beta: Budda Bing Bang Boom...
    Time to resurrect an oldie but a goodie… Dedicated to the flying Imams….
  • 123beta: Open Trackback Weekend #29...
    I hope everyone had a great Thanksgiving! Please feel free to leave a post and I’ll be sure to send a trackback your way. …
  • The Business of America is Business: End It Like Beckham...
    In a bid to boost its competitiveness, its image, and its gate receipts, Major League Soccer (MLS) is changing its rules. The rules concern not...
  • Test Track: I got in a fight with my dad. :(...
    I remember I was hammering on a fence in the backyard when my dad approached me. He was carrying a letter or something in his hand, and he looked worried. I continued...
  • BRING IT ON: Mark 11:23-24
    Mark 11:23-24 For verily I say unto you, That whosoever shall say unto this mountain, Be thou removed, and be thou cast into the sea; and shall not doubt in his heart,...
  • Renaissance Blogger: Another Strike Against Children’s Innocence...
    I don’t think I’ve seen anything that has bothered me as much as this toy being marketed to four and five year olds as a fitness product. From the...
  • Committees of Correspondence: You can't always get what you want......
    “The Lesser of two Evils” is a saying that has been cropping up in recent years. This is what is called a “cliche”. Cliches...
468x60-2

Dynamic CSS using ASP.NET MVC

I’ve been considering the usefulness of adding a CSS management system to my CMS that I’ve been working on. Here are the steps I’ve taken to implement it.

  1. Create a new MVC applictaion
  2. Open /Views/Shared/Site.Master
    1. <link href=”/Css/Site.css” rel=”stylesheet” type=”text/css” />
    2. This doesn’t point to anything yet
  3. Open Global.asax
    1. Add a MapRoute
      1. routes.MapRoute(“Css”, “Css/{cssFile}.css”, new { controller = “Css”, action = “Index”, cssFile = “Site” });
      2. Now /Css/Site.css points to Css/Index
  4. Add a class Css.cs to Models
    1. Add public string Body { get; set; }
    2. Add public string Width { get; set; }
    3. Add public string Background { get; set; }
  5. Add definitions as desired
  6. Add a view for CssController/Index
    1. Make it strongly typed with CSScontrol.Models.Css as the model
  7. Change contenttype in page directive of Views/Css/Index.aspx to “text/css”
  8. That should do it.

I’m not sure that I’m convinced of the usefulness of this idea but it’s possible and easy to implement in your ASP.NET MVC project. The possibility of using variables in a CSS file is intriguing.

You may download a sample of the MVC2 project here. Let me know if this is a good idea, a horrible idea or just a bit interesting.

Edit – I’ve added a Response.Filter to this to remove extra spaces, tabs, carriage returns/new lines, final semicolons and comments. It brought the 4.96kb file down to 2.74kb.

Posted in ASP.NET, C#, MVC, Programming by Mark (26Feb10 @ 0946)

Trackback | Permalink | 4 Comments

Adding links to all pages on a site using CSS

OK, I named this post that so that perhaps google will pick it up and those new to CSS will find this post.

There is a really good reason that there are no tutorials on the internet concerning how to add content (a site menu is the most common request) to all the pages on your web site using CSS. That’s because CSS doesn’t control content. It controls styling and nothing more. You don’t use styling to add content.

Why not look into some sort of server side includes. PHP includes will handle the situation. ASP.old can handle it but don’t use it unless you have no other choice (and you do). If you’re really fancy and modern and handsome and awesome you can just use ASP.NET MasterPages and/or User Controls. :)

To wrap it up, CSS doesn’t do that. Stop asking about it! Thank you.

Posted in Programming, Web design, Web standards by Mark (23Feb10 @ 2119)

Trackback | Permalink | Comments Off

Finding the current season using C#

Recently someone challenged me to write a server-side method for finding the current season and changing a style sheet accordingly.

The first step is deciding how to differentiate the seasons. I figured to use the day of the year so that astronomically Spring begins on March 21st, the 80th day of the year. Summer begins on the 172nd day, Autumn, the 266th and Winter the 355th. Of course, on a leap year add one day to each, 81, 173, 267 and 356.

Now to find the day of the year use the DayOfYear property. Also, use the IsLeapYear property to take a day away on leap year if the current day is after February 28th (the 59th day of the year). This is easily done by converting the bool IsLeapYear to an Int32 giving a 0 during non-leap years and 1 during leap year.
int doy = DateTime.Now.DayOfYear - Convert.ToInt32((DateTime.IsLeapYear(DateTime.Now.Year)) && DateTime.Now.DayOfYear > 59);

Then find the current season using a few nested ternary operators (I like ternary operators)
string currentSeason = String.Format("{0}.css",((doy < 80 || doy >= 355) ? "winter" : ((doy >= 80 && doy < 172) ? "spring" : ((doy >= 172 && doy < 266) ? "summer" : "fall"))));

I use this in the head of my MasterPage:
<link rel="Stylesheet" runat="server" id="seasonSheet" type="text/css" />

So all I have to do to add the correct style sheet for the current season is this:
seasonSheet.Attributes.Add("href",currentSeason);

Now a stylesheet named spring.css, summer.css, fall.css or winter.css will be added to your rendered MasterPage.

I hope you’ve found this helpful.

Posted in ASP.NET, C# by Mark (28Dec09 @ 1518)

Trackback | Permalink | No Comments

SCOPE_IDENTITY() with LINQ

While reading about a recent question concerning @@Identity and the reasons to use SCOPE_IDENTITY() instead I experimented with LINQ to get the SCOPE_IDENTITY() results.

 using (var dbc = new siteDataContext())
    {
        dbc.Log = Console.Out;
        repertoire newSkill = new repertoire
            {
                skill = "a new item"
            };
        dbc.repertoires.InsertOnSubmit(newSkill);
        dbc.SubmitChanges();
        Console.Write(newSkill.id.ToString());
    }

It seems that calling the id column of the inserted object gives you the SCOPE_IDENTITY(). Here is the SQL Log:

INSERT INTO [dbo].[repertoire]([skill])
VALUES (@p0)
SELECT CONVERT(Int,SCOPE_IDENTITY()) AS [value]
-- @p0: Input NVarChar (Size = 10; Prec = 0; Scale = 0) [a new item]
-- Context: SqlProvider(Sql2008) Model: AttributedMetaModel Build: 3.5.30729.1

Posted in ASP.NET, C#, LINQ, Programming by Mark (31Oct09 @ 1058)

Trackback | Permalink | No Comments

Sweet rhythm section

http://www.youtube.com/watch?v=jbN-jO11vKg

Posted in Humor by Mark (29Jun09 @ 1818)

Trackback | Permalink | Comments Off

Music really does set the mood

http://www.youtube.com/watch?v=Kr-e3qGQ884

:lol:

Posted in Humor by Mark (15Apr09 @ 2105)

Trackback | Permalink | Comments Off

71.5% of screen reader users find Flash difficult to use

WebAIM‘s Screen Reader Survey, conducted December 2008 to January 2009, is a very interesting read. Yet another nail in the Flash coffin but surprisingly Frames are deemed easy to use by nearly 60% of screen-reader users.

Give it a quick look. Comments open.

Posted in Web design, Web standards by Mark (10Feb09 @ 2033)

Trackback | Permalink | No Comments

« Previous Entries

Sponsored links

468x60-1 email address
Google
Custom Search

Amazon Wishlist

Hello, friends! I've decided to put my Amazon wishlist online. If you feel nice today you can purchase one of the items listed and it will be shipped to my door. My birthday is May 13th and I will gladly accept gifts for any Christian or Jewish holiday. Thank you for your support.

Site search and links

I'm a friend of Israel

234x60

Open Trackback Alliance Logo


Widgetize!
WWW is deprecated
no-WWW class B
free email addresses
*blogs that link here powered by Technorati

©2010 imaginekittymagazine