ITmeze - IT world server like cyprus meze

Recent blog posts Tagged 'web'

Getting ugly with BeginActionLink helper!

Itmeze

Have You ever had such a moment when the most stupid and trivial solution turns out to be the ONLY ONE that is logically suitable at the moment? When I had such a feeling today.... I am working on a module for one of huge web portals (not to mention which one). Part of that module is only accessible to users with administration permissions - as typical as it can be. The reason why I am mentioning that is to highlight the fact that at this specific part performance does not matter so much. Anyway, my talk to one of designers (Friday, half an hour before 'the beginning of the weekend'): Designer: I am going to spend whole weekend on those Views... Me: Yeah... S*** happens.... Designer: Those 'Html.ActionLink' that You use everywhere, how do I put something inside, you know, images, spans, staff like that... Me: Argh... Hm..... I suddenly realize that before I leave the office this guy needs an extension method: BeginActionLink like right now!. The similar one that is used for Forms elements (BeginForm). Then I started to code... Have You ever realized that ActionLink has roughly 12 overloads!!!! That would take hours to prepare BeginActionLink for most of them. idea bulb When You are blocked, what You do? Me too, I started 'googling'. Nothing simple and smart enough. Except 200 lines of code with tons of overloads... argh... But then, completely unexpectedly .... My moment of genius! Don't laugh! For people over ... some age ... that things do not happen offen! :) There are solutions that developers are ashamed of, but they simply do their job:
public static string TrimEndTag(this MvcHtmlString htmlString, string tagName = "a")
        {
            var endTag = new TagBuilder(tagName).ToString(TagRenderMode.EndTag); 

            var tagString = htmlString.ToString();

            var endTagIndex = tagString.LastIndexOf(endTag);

            if(endTagIndex > 0)
                tagString = tagString.Remove(endTagIndex).TrimEnd();

            return tagString;
        }

        public static string ToEndTag(this HtmlHelper html, string tagName)
        {
            return new TagBuilder(tagName).ToString(TagRenderMode.EndTag);
        }
I am simply removing end tag from ActionLink returned string! As simple as that! So all that is left for my buddy to do is to use it like that:
<%= Html.ActionLink(" ", "testAction", "testController", new { id = 4 }, new {}).TrimEndTag() %>

        images, spans, text, whatever...

    <%= Html.ToEndTag("a") %>
Wuala! Ugly, So ugly, but at the same time I am preserving original methods for ActionLinks and I couldn't figure out better solution....

Tags: [actionlink] [asp.net-mvc] [htmlhelpers] [web] [web development]

Something is just wrong with this CAPTCHA!

Itmeze

Everyone knows what CAPTCHA is. This few weird letters/word that you write down to prove that you are a human. There are ton's of them all around. Here and there. Often people (or developers) overuse them on web sites, which can be really annoying. I was trying to register on one of the web sites today. After filling 16 (literally: sixteen) required fields on some really strange wizard I finally come up to form submission. This is what i saw: weird catcha Yeah, pretty straightforward. I thought. After filling input with PHN i saw JavaScript alert: 'Invalid captcha!. Please try again'. I tried. And again the same. I was just about to abandon whole the process, but it all looked so strange i decided to  check what is going on in firebug. And then i figured out that actually valid input would be: 'green'. WHAT? Then I have read carefully what was written below the image: 'If You are happy please type the color of the second character'. Argh! Wasn't that obvious? WEB DEVELOPERS! PLEASE, DON'T MAKE OUR LIFE DIFFICULT! DON'T LET US THINK! What a stupid idea to make so common thing other way around! Or maybe it is okay, and this was my fault/foolishness not to read what was written? What You think? Do You know any other weird CAPTCHA?

Tags: [captcha] [web] [web development]

Short history of Facebook

Itmeze

If You haven't seen or did not follow how world most popular social network changed over lat couple of years just take a break and spend next 4 minutes watching movie below. And wow, just look at those numbers! RESPECT to Mark Zuckerberg! After that I feel like an ant in today's world. I also recommend visiting web site: CheckFacebook. Where you can get some up to date stats about popularity and growth of Facebook user's all over the world. Here is a simple screen shoot: checkfacebook user's in cyprus It looks like it is pretty popular in Cyprus as well  - third of population....

Tags: [checkfacebook] [facebook] [internet startup] [web] [web development]

Copyright 2013 © ITmeze