DCSIMG
January 2010 - Posts - A Bit Lighter

A Bit Lighter

Simple things that may help you

January 2010 - Posts

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:

image

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:

image

Posted: Jan 20 2010, 10:56 AM by egoldin | with 2 comment(s)
תגים:, ,