Attention: We are retiring the ASP.NET Community Blogs. Learn more >

Contents tagged with Techie Stuff

  • ASP.NET 1.1 server control for <link> - enabling relative URL paths using tilde "~"

    Here's a simple - but useful Link webcontrol class that supports the "~" tilde syntax for relative paths for the href attribute of the <link> element.

    [DefaultProperty("Text"),ToolboxData("<{0}:Link runat=server Href=\"\" Rel=\"Stylesheet\" Type=\"text/css\"></{0}:Link>")]
    public class Link : System.Web.UI.WebControls.WebControl
    {
        private string _href;

        public string Href
        {
            get { return _href; }
            set { _href = value; }
        }

        protected override void Render(HtmlTextWriter output)
        {
            output.WriteBeginTag("link");
            output.WriteAttribute("href",base.ResolveUrl(this.Href));
            foreach (string key in this.Attributes.Keys)
            {
                output.WriteAttribute(key,this.Attributes[key]);
            }
            output.Write(HtmlTextWriter.TagRightChar);
            output.WriteEndTag("link");
        }
    }

    You can then simply drop it in the <head> section of your page (provided you've used the Register directive to register the assembly):

    <cc1:Link id="Link1" runat="server" Type="text/css" Rel="Stylesheet" Href="~/my.css" myattribute="Whatever"></cc1:Link>

    The reason I had to roll my own is that when you add runat="server" for the <link> element, it turns into a HtmlGenericControl instance on the server, which is obviously used for numerous HTML elements, and as such no specific path resolve mechanism is applied to any of its attributes, since the attributes are different per HTML element.

    Hope it helps someone out.

  • PayPal API: what a nightmare!!!

    I've been trying to get up and running with the PayPal API, see www.paypal.com/developer.What a complete nuisance that is!

    The test accounts you create (on the sandbox, http://www.sandbox.paypal.com) actually need to be verified, before you can request an API cerificate. I finally managed to complete 2 out of the 3 verification steps but setting up the bank funding just fails:

    I can add a US bank account, and according to the documentation (PP_Sandbox_UserGuide , page 22), you will see the 'Continue' button after adding an account which will take you to the overview page. Well, there is no 'Continue' button, and no 'Confirm Bank Account' link in the Activate  Account box either, which means I cannot complete that step, and can't request an API cert. to start using the API.

    I have tried to add a UK bank account, using the sortcode prodived in the same user guide, but it always fails saying that it's an incorrect sort code and incorrect 8 digit account number.

    Why the bloody heck is their documentation inconsistent with the behaviour of the sandbox? And why on earth do people have to jump through so many hoops to use their API?

    Have you used the PayPal API? Any thoughts on this?

  • Hack: turn your optical mouse into a scanner

    Why? Because it can be done. :-)

    "Ever wonder what your desk surface looks like up close? No. No one has. Not even [Sprite_tm], but upon disassembling his optical mouse and discovering its 18x18 CCD he decided to put it to use (well, a different use). The optical chip outputs serial information to the USB chip in the mouse. [Sprite_tm] wired the optical chip to a parallel port and wrote a simple program to interpret the data. Not really useful, but it does generate some interesting pictures. Program provided, natch."



    Via: Hackaday.com

    Very cool, indeed.

  • Tesco's UK - only 3,000 XBOX 360's at launch....!!!

    Just been told by a member of staff of Tesco, here in the UK that there's only around 3,000 XBOX 360's in Britain. I'm definitely guessing he meant 3,000 XBOX 360's at launch with Tesco's, which seems like an incredibly small amount for such a big superstore.

    I phoned a big Tesco Extra's store in Swansea, Wales. They only had 11 XBOX 360's in! And people had been waiting for them from 6'o clock...

    Surely MS must be putting some pressure on the production of these units! Get on with it! If you want to win the battle with Sony's PS3, better increase production! Sounds like the demand is enormous...despite the rumours of crashes and BSOD's etc.

  • Why don't we see any patches for Visual Studio .NET? (2002, 2003, 2005...)

    Frans has mentioned this on numerous occasions I believe, and this topic has reared its ugly head once again. Dan Fernandez' post back in March 2004, doesn't really address the reasoning behind it.

    Personally, I really don't see the difficulty for Microsoft in releasing publicly available patches or hotfixes for VS.NET. It happens for the .NET framework, all OS'es and Office products, why not for VS.NET?

    At the lowest level, it's only shuffling around a few bits and bytes for the affected binary files. Even with the different VS.NET product versions, they could release a patch for each version if needs be.

    Anyone care to comment on the reasoning behind this?

  • The pollution on the main weblogs.asp.net feed...

    When I go through the main feed here on weblogs.asp.net, the last thing I'm looking for is:

    - Posts in any other language but English. I'm saying that as a Dutch native speaker.
    - Simply regurgitated posts from (wait for it...) weblogs.asp.net!!! Sometimes it even is regurgitation upon regurgitation...
    - How many virtual bucks your blog is worth.
    - Politics or completely unrelated things like non-technical news items. If I want to read the news, I'll check out the BBC, CNN, MSNBC and other sources, thanks.

    What am I looking for? Well:

    - Posts with technical content, related to Microsoft or competitive technologies.
    - Techical news items, gadgets, technologies, architecture, tools; as long as it hasn't been posted or linked to before on weblogs.asp.net.
    - Links to blog posts outside of weblogs.asp.net which contain content similar to the above.

    I may have missed out some, please let me know your thoughts. If we all stuck to it (even only 80% of the time), the mainfeed would be much, much cleaner.

    I guess having global categories when posting, and the ability to exclude global categories on the mainfeed and for the RSS feeds (personalized setting) would help. Anyone know whether this exists in CS 2.0?

  • MSN Search textbox: make the thing wider!

    How annoying is that little MSN search input textbox. Especially if you specify a literal string query which contains several words and combine this with some other logical AND or OR search terms.

    Just quadruple its width!

    Google has had a decent textbox since its inception...

    You'd have thought the MSN folks would have learnt something from Google by now.

  • MD5 or SHA1 hashing - the easy way

    This is a typical example of a static method which IMHO is in the wrong namespace.

    If you're looking to use an MD5 or SHA1 hashing algorithm to hash passwords, a lot of people would start looking in the System.Security.Cryptography namespace. But the System.Web.Security namespace offers us the FormsAuthentication.HashPasswordForStoringInConfigFile() static method:

    string pwhash = FormsAuthentication.HashPasswordForStoringInConfigFile(password, "md5");

    The second parameter can be either "md5" or "sha1".

    As far as I'm concerned, simple hashing and enrypt and decryption methods (static) should've been in System.Security.Cryptography in the first place.

    What do you think?