in

ASP.NET Weblogs

uber1024's WebLog

It's not hot wings and beer, but it's still okay

April 2005 - Posts

  • Making an RSS feed available to Firefox's Live Bookmarks

    If you add:

      <link rel="alternate" type="application/rss+xml" title="RSS" href="/my_rss.rss">

    to your page, Firefox can detect that and add an RSS feed to your bookmarks.  A little orange icon appears in the lower right hand corner of the browser window and if you click on it, you can add the feed to your bookmarks.  Now that I'm using Firefox more and more, I'm trying to learn how to, as a web developer, leverage some of its features.  That way I won't feel so bad as Firefox continues to gain market share (I heard that it just hit 10%) and the inevitable double-publishing starts again.

    In my last post, I made some mixed comments about Firefox and I got a number of emails, a very small number of which were almost readable, that appeared to say that hating on the pinnacle of humanity was akin to touching children.  If I get more, my next post will be entitled "Firefox is the browser Pol Pot would have used," even though I use Firefox almost exclusively.  Firefox has some very good features (tabbed browsing being the possibly the best thing since web browsers started -- and YES, I know that Opera had it first, and this RSS thing has the potential to be very cool as I learn more about it) and some very bad features (it takes up a near blasphemous amount of virtual memory if you use it for longer than the average lifespan of a Mr Softee ice cream cone in July, and waiting for it to process a lot of Javascript is like watching ketsup come out of the bottle).  But let me repeat ... I like Firefox.  I recommend it to my friends.  I use it.  Probably more than you.  I'll take the bad with the good, as I'm sure that both are going to get better over time.

  • Firefox's tabbed browsing makes statelessness cool again

    The web was originally stateless and we've done everything we can to change that over the years.  Hidden viewstates, sessions, cookies, and XMLHttp are all ways to help make web applications ... well ... less like web applications.  This isn't good or bad, it's just what's happening.

    However, the rise of Firefox as the preferred browser among the tech-savvy says something ... people LOVE tabbed browsing.  It's quite possible that if Microsoft doesn't release a version of IE without tabbed browsing, IE's dominance could be in some trouble.  Firefox is slower, more bloated, and less stable than IE, but people love it and many would take a kick to the jimmies before switching back.

    With this in mind, the less state that certain types of pages have, the more useful they become.  When you can encode data that a page needs in the querystring you make it more useful to tabbed browsers, as users can pass this information to a page easily.  After making this realization, when I've been making web-based tools for myself and others that I know use Firefox, I put everything in the querystring, like most of us used to do a few years ago before ASP.NET.  The backend for one of my messageboard sites has lists of posts with "delete this" links with URLs like:

    MacDaddy.com/backend/forum_admin.aspx?mode=delete&post_id=123456

    and pass no other information (although session information is passed via a cookie).  Until I started using Firefox more, I had bought into ASP.NET's new practices wherein data got stuffed into viewstates and I checked IsPostBack right from the start.  But these days, that probably won't be happening so much.  My sites are moving in one of two directions, neither of which leverages some of ASP.NET's features.

    One direction is what I just talked about, making sites less stateful.  The other thing I've been doing lately is keeping state information in XML and using SOAP/XSL to handle a lot of the interaction between the page and the web server.  I'll blog more about this way later and I'll try to include code.

    So, as always, our industry marches on and we have to also.  I know that many people are excited about ASP.NET 2.0 and SQL Server 2005, but I have a feeling that Firefox might have a bigger impact on web development than anything Microsoft releases this year (assuming that developers learn how to leverage some of the features of Firefox).  I'll qualify that by saying that all my information about ASP.NET 2.0 and SQL Server 2005 comes from bloggers and that I'm likely to adopt both as quickly as possible, but I still think that Firefox is a big deal.

  • Searching a datetime field for just the time

    Another situation I ran across was to search for events that started between 1pm and 4pm, for example.  SQL Server does not do this nicely, as far as I can tell.  To do this search, you need to leverage the fact that datetimes are basically floats:

    SELECT * FROM MyTable

    WHERE StartDate - CAST(FLOOR(CAST(StartDate AS float)) AS datetime) > '13:00'

    AND StartDate - CAST(FLOOR(CAST(StartDate AS float)) AS datetime) < '16:00'

    Having done many projects that center around dates and times, working with these constructs is never easy.  Even the .NET runtime doesn't really have great functionality for doing this, and it seems that every product and language deals with them slightly differently.  For example, SQL Server deals with fractions of a second with a decimal point:  HH:MM:SS.mmm whereas javascript does the same with a colon:  HH:MM:SS:mmm  This doesn't seem like it would be a problem until you're passing data around as XML, which is basically a string.  All of a sudden, one half of your application is emitting strings that the other half can't use.

    And this is just dealing with the same time system.  Don't even get me started on converting between Gregorian dates and Hebrew dates or trying to compute whether it's daylight savings time in a particular country (or part of a country)!  If you want to watch someone's head explode, tell them to write an IsDaylightSavingsTime function that, given a day, time, and country/state, will return true or false.

  • Combining date and time into one value in SQL Server

    I have a project where I need to upload a date and a time seperately into SQL Server, yet they need to be in one field in the database.  Here is a sketch of the solution:

    CREATE PROCEDURE zzz_JohnTest @StartDate datetime, @StartTime varchar(50)
     AS

    declare @startdatetime datetime

    declare @strDateTime varchar(200)

    -- this next line converts the date parameter to a string in the format of "MM/DD/YYYY" and adds the time

    select @strDateTime = Convert(varchar(100), @StartDate, 101) + ' ' + @StartTime

    select @startdatetime = cast (@strDateTime as datetime)

    select @startdatetime as StartDateTime
    GO

More Posts