Web App label text centering

Hi,

     I have a label in a web app.  It displays a barcode for whatever item is selected.  Some are long, some are short, so I want the text in the label to be centered.  The box is right above a button to print the barcode, so it looks strange when the barcode hangs way to the left of the box.

Thanks!

JP
gleznovAsked:
Who is Participating?
 
iboutchkineCommented:
you have to add styles to the textbox or label

.TextBoxAlignRight
{
    text-align : right;
}

<asp:TextBox id="tb1" runat="server" CssClass="TextBoxAlignRight" />


Then drag and drop Styles.css to the form

for center alignment
.TextBoxAlignCenter
{
    text-align : center;
}
0
 
gleznovAuthor Commented:
Can you give me more info?  That looks like java?  Where do I put that?  VB code?  HTML?

JP
0
 
iboutchkineCommented:
If you open any web appplication, in the solution explorer you will see Styles.css file. This is cascading style sheet file.
Double click on it and modify it there. Or another choice is to create your own css file and add to the project. When you finish modification, drag this file from the edxplorr to the page to apply to the whole page . Or if you want to apply to only on econtrol, go to the properties and enter the nyme of css to the CssClass properties
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
gleznovAuthor Commented:
Here's what I've got:

/* Default CSS Stylesheet for a new Web Application project */

BODY
{
    BACKGROUND-COLOR: white;
    FONT-FAMILY: Verdana, Helvetica, sans-serif;
    FONT-SIZE: .8em;
    FONT-WEIGHT: normal;
    LETTER-SPACING: normal;
    TEXT-TRANSFORM: none;
    WORD-SPACING: normal
}

.TextBoxAlignCenter
{
    text-align : center;
}

H1, H2, H3, H4, H5, TH, THEAD, TFOOT
{
    COLOR: #003366;
}
H1      {      
      font-family: Verdana, Arial, Helvetica, sans-serif;
      font-size:      2em;
      font-weight:      700;
      font-style:      normal;
      text-decoration:      none;
      word-spacing:      normal;
      letter-spacing:      normal;
      text-transform:      none;
      }      
            
H2      {      
      font-family: Verdana, Arial, Helvetica, sans-serif;
      font-size:      1.75em;
      font-weight:      700;
      font-style:      normal;
      text-decoration:      none;
      word-spacing:      normal;
      letter-spacing:      normal;
      text-transform:      none;
      }      
            
H3      {      
      font-family: Verdana, Arial, Helvetica, sans-serif;
      font-size:      1.58em;
      font-weight:      500;
      font-style:      normal;
      text-decoration:      none;
      word-spacing:      normal;
      letter-spacing:      normal;
      text-transform:      none;
      }      
            
H4      {      
      font-family: Verdana, Arial, Helvetica, sans-serif;
      font-size:      1.33em;
      font-weight:      500;
      text-decoration:      none;
      word-spacing:      normal;
      letter-spacing:      normal;
      text-transform:      none;
      }      
            
H5, DT      {      
      font-family: Verdana, Arial, Helvetica, sans-serif;
      font-size:      1em;
      font-weight:      700;
      font-style:      normal;
      text-decoration:      none;
      word-spacing:      normal;
      letter-spacing:      normal;
      text-transform:      none;
      }      
            
H6      {      
      font-family: Verdana, Arial, Helvetica, sans-serif;
      font-size:      .8em;
      font-weight:      700;
      font-style:      normal;
      text-decoration:      none;
      word-spacing:      normal;
      letter-spacing:      normal;
      text-transform:      none;
      }      
            
TFOOT, THEAD      {      
      font-size:      1em;
      word-spacing:      normal;
      letter-spacing:      normal;
      text-transform:      none;
      font-family: Arial, Helvetica, sans-serif;
      }      
            
TH      {      
      vertical-align:      baseline;
      font-size:      1em;
      font-weight:      bold;
      word-spacing:      normal;
      letter-spacing:      normal;
      text-transform:      none;
      font-family: Arial, Helvetica, sans-serif;
      }      

A:link      {      
      text-decoration:      none;
      color:      #3333cc;
      }      
            
A:visited      {      
      text-decoration:      none;
      color:      #333399;
      }      
            
A:active      {      
      text-decoration:      none;
      color:      #333399;
      }      
            
A:hover      {      
      text-decoration:      underline;
      color:      #3333cc;
      }
      
SMALL      {      
      font-size:      .7em;
      }      

BIG      {      
      font-size:      1.17em;
      }      

BLOCKQUOTE, PRE      {      
      font-family:      Courier New, monospace;
      }      
      

UL LI      {      
      list-style-type:      square ;
      }      

UL LI LI      {      
      list-style-type:      disc;
      }      

UL LI LI LI      {      
      list-style-type:      circle;
      }      
      
OL LI      {      
      list-style-type:      decimal;
      }      

OL OL LI      {      
      list-style-type:      lower-alpha;
      }      

OL OL OL LI      {      
      list-style-type:      lower-roman;
      }      

IMG       {
      margin-top: 5px;
      margin-left: 10px;
      margin-right: 10px;
      }


Did I put that in the wrong place?  I put the name of the CSS file into the parameter for that control, but it still doesn't center the text.  Do I need to do something else?

JP
0
 
gleznovAuthor Commented:
<asp:label id="lblBarCode" style="Z-INDEX: 138; LEFT: 448px; POSITION: absolute; TOP: 488px"
                        runat="server" Font-Size="XX-Large" Font-Names="Free 3 of 9" Height="48px" Width="256px" CssClass="TextBoxAlignCenter" CssClass="StyleSheet1.css >

for the button - I've tried both of the CssClass, I included both in the above example just for simplicity, but each time I've run it, only one or the other was there.

JP
0
 
iboutchkineCommented:
I did it for the text box and everything worked fine. Maybe for the label it is not TextBoxAlign? I am not sure
0
 
gleznovAuthor Commented:
Hmmm, trying some things, but no luck yet.

JP
0
 
gleznovAuthor Commented:
I dunno.  Any ideas?

JP
0
 
iboutchkineCommented:
No clue. But try to put
.TextBoxAlignCenter
{
    text-align : center;
}

into default css file and then try again
0
 
gleznovAuthor Commented:
That's the one that didn't work - I tried:

.LabelAlignCenter
{
     text-align : center;
}

but no luck there either.

JP
0
 
gleznovAuthor Commented:
I finally wrote a routine to do it myself.  Thanks for trying though.

JP
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.