The 'When Was I Last Clicked On' Feature

The time has come.  I'm at work, I'm bored, and I'm in the mood to publish something.

So, here it is, what you've all been secretly waiting for ever since you saw it (don't lie).  Here is how to download and 'install' the small control that shows you how long it was since it was last clicked on.  Yes, that's all it does.

First of all, download the file from here: ResetButton.zip (2.75 kb) [Downloads: 3]

Inside that ZIP file is a readme explaining everything.  However, if, like me, you don't like reading ugly, unformatted readmes in Notepad, here's a nicer-looking version:


Overview

To see this in action, visit www.creepinjesus.net.  It is located at the top of every page, next to the main navigation buttons.

This add-on for .NET BE could be used in practically any ASP.NET web project, as it uses a standard .ascx file and .ascx.cs C# code-behind file.  I have tested the control in version 1.3 and 1.3.1 of the .NET Blog Engine system.

As for version 1.4 (the latest release), I'm not sure about.  However, after looking at the new 'widget' system in place in v1.4, I think it could work with no problems - but it would require some re-coding.  Until that's done, you can use it in the same way as described below (i.e., not as a widget).

How to use:

  1. Extract the contents of the .zip file to wherever you like.
  2. Copy the two files, "TheResetButton.ascx" and "TheResetButton.ascx.cs" to the User Controls folder inside your blog application folder (typically C:\inetpub\wwwroot\blog\User Controls).
  3. To add the control to your page, add the following line at the top of the page's source code:
    <%@ Register Src="~/User controls/TheResetButton.ascx" TagName="ResetButton" TagPrefix="PointlessGadget" %>
    Note: you can choose anything you like for the TagName and TagPrefix, but the 'Src' field must point to the location of the .ascx file.
  4. If you don't already have one, make sure there is a ScriptManager somewhere in the page.  This control uses an UpdatePanel, which needs a ScriptManager to work.  Add this line to the page to insert a ScriptManager:
    <asp:ScriptManager ID="ScriptManager1" runat="server" />
    I added mine right after the <form> tag at the start of the page.
  5. Add the following tag to the page in the location where you want the control to appear:
    <PointlessGadget:ResetButton id="ResetButton" runat="server" />
    (to explain: <[TagPrefix]:[TagName] id="... /> )
  6. Create an .xml file in the folder of your choice.  I chose the App_Data folder, as it is already configured to be accessible by the application.  Give the .xml a name like 'TimeStamp.xml', or something you find useful.
  7. Open the TimeStamp.xml file.  Insert the following data into the file:
    <?xml version="1.0" encoding="utf-8"?>
    <timestamp></timestamp>
  8. Edit the .cs code-behind file so that the path to the XML file matches that of the file you created in Step 6.
  9. Open up your website and browse to a page containing the control.  It should say " since somebody clicked this!" (i.e., no time stamp).  This means it's working!  Simply click once on the link and the text should update (without reloading the page).  A time stamp will be created in the .xml file.
  10. All done!  Enjoy the uselessness of this add-on.

Licensing

Basically, feel free to do what you want with this.  Its not exactly Nobel Prize-winning code - I think most of you could probably make your own version of this in no less than an hour.

Attribution But, just for the sake of professionalism, its licensed under the Creative Commons Attribution 3.0 license (more info: http://creativecommons.org/licenses/by/3.0)

Rated 3.6 by 7 people

  • Currently 3.571429/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Posted by CreepinJesus on 7/7/2008 at 11:16 AM

Tags: ,
Categories: How-To | Look What I Made :)
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Post RSSRSS comment feed

Comments are closed - no more comments can be made to this post.