The new new way to make a link



  • I'm in an independent study this semester, and our project has been to build a statistics website. In this group, there is myself, a student from another university (who we haven't seen in two months), trendy unexperienced Web 2.0 guy, and unexperienced dimwit, whom I will call Chance, as you never know whose piece of the project he will screw up next.

    Chance has been particularly annoying to me, as I appear to be the pseudo-leader of this group and thus all his dumb questions come to me. For example, "how do I retrieve a url in a Django template?" or "why isn't {{ MEDIA_URL }} working for CSS?". Perfectly legitimate questions, mind you, but those who were offered a slot in this course were those who supposedly did well with this very same framework. Whoops.

    Thank god that this is the last week, and we have nothing to show for the entire semester. Of course, there is this little (anonymized) nugget that Chance wrote recently...


    <form>{% csrf_token %}
    <input type="button" value="Button Text" onclick="window.location.href='{% url path.to.view %}'">
    </form>



  • @Schlagwerk said:

    I'm in an independent study this semester, and our project has been to build a statistics website. In this group, there is myself, a student from another university (who we haven't seen in two months), trendy unexperienced Web 2.0 guy, and unexperienced dimwit, whom I will call Chance, as you never know whose piece of the project he will screw up next.

    Chance has been particularly annoying to me, as I appear to be the pseudo-leader of this group and thus all his dumb questions come to me. For example, "how do I retrieve a url in a Django template?" or "why isn't {{ MEDIA_URL }} working for CSS?". Perfectly legitimate questions, mind you, but those who were offered a slot in this course were those who supposedly did well with this very same framework. Whoops.

    Thank god that this is the last week, and we have nothing to show for the entire semester. Of course, there is this little (anonymized) nugget that Chance wrote recently...


    <form>{% csrf_token %}
    <input type="button" value="Button Text" onclick="window.location.href='{% url path.to.view %}'">
    </form>

    Everyone has to coperate and work. Is Chance person devius natured or good natured?



  • @Schlagwerk said:

    <form>{% csrf_token %}
    <input type="button" value="Button Text" onclick="window.location.href='{% url path.to.view %}'">
    </form>

    Isn't that how .Net works?  (I don't know if that made me sad or not)

    I actually haven't checked to see how horrifically a .Net page crashes and burns if you turn off Javascript.


  • Discourse touched me in a no-no place

    @Lorne Kates said:

    I actually haven't checked to see how horrifically a .Net page crashes and burns if you turn off Javascript.
    Vanilla asp.net controls actually degrade quite gracefully. Some of the fancier ajax and third party controls, however, do not. 



  •  @Schlagwerk said:

    onclick="window.location.href='{% url path.to.view %}'"
    groan

    I actually found that in our codebase once but thankfully when I pointed it out the guy that wrote it realized that it was a mistake and I never saw it again.



  • @Lorne Kates said:

    @Schlagwerk said:

    <form>{% csrf_token %}
    <input type="button" value="Button Text" onclick="window.location.href='{% url path.to.view %}'">
    </form>

    Isn't that how .Net works?  (I don't know if that made me sad or not)

    I actually haven't checked to see how horrifically a .Net page crashes and burns if you turn off Javascript.

    Why is it a .NET problem if a developer doesn't know how to use the Hyperlink control correctly?



  • @Schlagwerk said:

    <form>{% csrf_token %}
    <input type="button" value="Button Text" onclick="window.location.href='{% url path.to.view %}'">
    </form>



    I could find a legitimate use for this:

    Designer put a link that looks like styled button somewhere on the page.

    Before I start styling the link to look like a button I would add the snippet, although with action tag in form and without csrf token ...



  • @bjolling said:

    @Lorne Kates said:

    @Schlagwerk said:

    <form>{% csrf_token %}
    <input type="button" value="Button Text" onclick="window.location.href='{% url path.to.view %}'">
    </form>

    Isn't that how .Net works?  (I don't know if that made me sad or not)

    I actually haven't checked to see how horrifically a .Net page crashes and burns if you turn off Javascript.

    Why is it a .NET problem if a developer doesn't know how to use the Hyperlink control correctly?
     

    Not saying it is a .NET problem. Just saying that's the same way most .NET controls work.  You click/change them, and a piece of javascript fires that does a postback.  Look at a LinkButton with its PostBackUrl property set.

    I'm most certainly not defending the piece of dumbassery OP inflicted upon us-- just pointing out a parallel.



  • @Lorne Kates said:

    [quote user="Schlagwerk"]<form>{% csrf_token %}
    <input type="button" value="Button Text" onclick="window.location.href='{% url path.to.view %}'">
    </form>

    Isn't that how .Net works?  (I don't know if that made me sad or not)

    I actually haven't checked to see how horrifically a .Net page crashes and burns if you turn off Javascript.

    [/quote]

    Of course not! In ASP.NET, clicking the button would fire an AJAX call back to the server to execute the ClientClick event handler, which would send code back to the page that would open the new URL.

    And here you thought you would store things like URLs in client-side? Of course they might still. You can never tell what's on the clientside and what's on the serverside with ASP.NET!


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.