Thursday, July 31, 2008

Cool buttons with ASP.NET WebForms

The great guys at Particletree (makers of Wufoo), wrote a great article about really cool ways to style buttons:

Rediscovering the Button Element

If you make web sites, go read that post, it's great!

The cool thing is how both buttons and regular links look exactly the same, for me this means no more buttons with

onclick="window.location.href='foo'"
just regular links that look the way I want them to.

Of course, being a noob is hard, and I wasn't sure how to create '<button>' elements that perform a postback in ASP.NET WebForms, but a little Google searching later HtmlButton comes to the rescue, and that allows me to create these cool buttons and links that look like buttons:

Cancel

And the markup couldn't be simpler:

<div class="buttons">
  <button
      runat="server"
      onserverclick="SaveButton_Click"
      type="submit">
    Save
  </button>
  <a href="#">Cancel</a>
</div>

No comments:

Post a Comment