How to solve width problem in ASP.Net Password control

No.of Views953
Bookmarked0 times
Downloads 
Votes1
By  amalhashim   On  16 Apr 2010 10:04:21
Tag : ASP.NET , ASP.NET Controls
How to solve width problem in ASP.Net Password control
emailbookmarkadd commentsprint

Images in this article missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at info@codegain.com

 

Introduction

I came across a strange issue with Password input and IE browser. I have set the width property as same as that of the other controls. But while rendering it in IE, the width of Password field was coming as around 10 pixel less than the other control. The best way to get rid of this issue was using CSS.

Before applying CSS I was using the below code

<html xmlns="http://www.w3.org/1999/xhtml" >
   <body>
       <form id="form1" runat="server">
           <table width="25%">
               <tr>
                   <td style="width:100%; text-align:left">UserName: </td>                  
                   <td style="width:100%; text-align:left"><asp:TextBox ID="txtUserName" runat="server"></asp:TextBox></td>
               </tr>
               <tr>
                   <td style="width:100%; text-align:left">Password: </td>                  
                   <td style="width:100%; text-align:left"><asp:TextBox ID="txtPassword" TextMode="Password" runat="server"></asp:TextBox></td>
               </tr>
           </table>
       </form>
   </body>
</html>

And in IE it’s coming as, 

Image Loading

Resolution, I have defined the following style

<style type="text/css" >
       .TextBox
       {
           font-family: Arial, Tahoma, Verdana, Calibri;
           font-size: 12px;
           color: Black;
           height: auto;
           width: auto;
       }
   </style>

And modified the HTML as

<html xmlns="http://www.w3.org/1999/xhtml" >
   <body>
       <form id="form1" runat="server">
           <table width="25%">
               <tr>
                   <td style="width:100%; text-align:left">UserName: </td>                  
                   <td style="width:100%; text-align:left"><asp:TextBox CssClass="TextBox" ID="txtUserName" runat="server"></asp:TextBox></td>
               </tr>
               <tr>
                   <td style="width:100%; text-align:left">Password: </td>                  
                   <td style="width:100%; text-align:left"><asp:TextBox  CssClass="TextBox" ID="txtPassword" TextMode="Password" runat="server"></asp:TextBox></td>
               </tr>
           </table>
       </form>
   </body>
</html>

Now in IE it’s coming as 

Image Loading

Viola!!!!! issue resolved. Hope this helps.

 
Sign Up to vote for this article
 
About Author
 
amalhashim
Occupation-Software Engineer
Company-Aditi Technologies
Member Type-Senior
Location-Not Provided
Joined date-07 Jun 2009
Home Page-http://lamahashim.blogspot.com
Blog Page-http://lamahashim.blogspot.com
I have done my masters in Computer Applications and graduation in Computer Science. I have great passion in working with Microsoft tool and technologies. I am also a Microsoft Most Valuable Professional. Personally my objective is to design/develop applications which eases user experience and performs better in long run.
 
 
Other popularSectionarticles
Comments
There is no comments for this articles.
Leave a Reply
Title:
Display Name:
Email:
(not display in page for the security purphase)
Website:
Message:
Please refresh your screen using Ctrl+F5
If you can't read this number refresh your screen
Please input the anti-spam code that you can read in the image.
^ Scroll to Top