Login Control in IE8
If you have an ASP.NET Logon control on your page, likely you have noticed that IE8 renders it in a distorted way:
I guess the reason is because the input controls used for the User Name and Password are styled as width:20ex and IE8 treats ex-based width differently for inputs of type “text” and “password”.
There is a simple work-around fixing the problem.
Handle the OnInit event of the Login control like this:
protected void Login1_Init(object sender, EventArgs e)
{
System.Web.UI.WebControls.Login login = sender as System.Web.UI.WebControls.Login;
TextBox txtUserName = login.FindControl("UserName") as TextBox;
TextBox txtPassword = login.FindControl("Password") as TextBox;
txtUserName.CssClass = "FixedLogin";
txtPassword.CssClass = "FixedLogin";
}
and the CSS will be:
.FixedLogin
{
margin-top:1ex;
margin-left:1ex;
width:150px!important;
}
Enjoy the result:
