How to make HTML5 work in Internet Explorer: IE6, IE7, IE8

March 28th, 2011 admin

Having played with the html5 elements I came across a problem - they will be ignored by older IE browsers. So you won't be able to style html5 page that contains lines of code like this:

 
<header>This is header</header>
 

IEs will display the text as if it would be outside the "header" tag. The solution I've found is to fix it using javascript:

 
<!--[if lt IE 9]>

 
  <script type="text/javascript">
    document.createElement('header');
  </script>
 
<![endif]-->
 

How to apply the fix to the other html5 elements you can find right here

But how to fix that if the user have javascript disabled? - This is the question.

Posted in development, html | No Comments »

asp.net: how to make asp:button render a button tagname with type=submit

March 25th, 2011 admin

Sometimes when I try to style the asp:button I get pretty frustrated because it has its limitations as it's not a container so you can't add any elements inside it. The real question is - why did Microsoft not make it possible to change the asp:button behaviour so it would be the option which tag you want to render? [sigh]
There are some articles in the internet saying how you can fix that by using web control adaptors or even javascript.
But what I really wanted is to have a different control that would render what I wanted it to. So I came up with the solution of extending the standard asp:button and overriding a couple of methods in it. The code is below. It's very simple and seems to work for me.

 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.ComponentModel;
using System.Web.UI.WebControls;
 
namespace MyControls
{
    /// Class extending Button, but rendering button type='submit'
    public class ButtonSubmit : Button
    {
        public ButtonSubmit()
            : base()
        { }
 
        public string Value
        {
            get
            {
                string str = (string)ViewState["Value"];
                if (str != null)
                {
                    return str;
                }
                return string.Empty;
            }
            set { ViewState["Value"] = value; }
        }
 
        public override void RenderBeginTag(HtmlTextWriter writer)
        {
            AddAttributesToRender(writer);
            writer.RenderBeginTag(HtmlTextWriterTag.Button);
        }
 
        protected override void RenderContents(HtmlTextWriter writer)
        {
            if (HasControls())
                base.RenderChildren(writer);
            else
                writer.Write(Text);
        }
 
        protected override void AddAttributesToRender(HtmlTextWriter writer)
        {
            // substitute "text" with "value" because the base class uses "text" for "value"
            string strText = Text;
            Text = Value;
            base.AddAttributesToRender(writer);
            Text = strText;
        }
    }
}
 

Posted in asp.net, c#, development, Uncategorized | No Comments »

How to Install IE9 on Windows XP

March 17th, 2011 admin

This is just not fair. If you're a web developer and you've got Windows XP running on your machine - Microsoft actually force you to pay them in order to upgrade your system. I've come across this article telling us about the ways you can use to install Internet Explorer 9 on Windows XP. But apparently - you can't do this. So spend some money and be happy.

Posted in Uncategorized | No Comments »