Solved

Web App label text centering

Posted on 2004-11-02
183 Views
Last Modified: 2010-04-23
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
0
Question by:gleznov
    11 Comments
     
    LVL 28

    Accepted Solution

    by:
    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
     

    Author Comment

    by:gleznov
    Can you give me more info?  That looks like java?  Where do I put that?  VB code?  HTML?

    JP
    0
     
    LVL 28

    Expert Comment

    by:iboutchkine
    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
     

    Author Comment

    by:gleznov
    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
     

    Author Comment

    by:gleznov
    <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
     
    LVL 28

    Expert Comment

    by:iboutchkine
    I did it for the text box and everything worked fine. Maybe for the label it is not TextBoxAlign? I am not sure
    0
     

    Author Comment

    by:gleznov
    Hmmm, trying some things, but no luck yet.

    JP
    0
     

    Author Comment

    by:gleznov
    I dunno.  Any ideas?

    JP
    0
     
    LVL 28

    Expert Comment

    by:iboutchkine
    No clue. But try to put
    .TextBoxAlignCenter
    {
        text-align : center;
    }

    into default css file and then try again
    0
     

    Author Comment

    by:gleznov
    That's the one that didn't work - I tried:

    .LabelAlignCenter
    {
         text-align : center;
    }

    but no luck there either.

    JP
    0
     

    Author Comment

    by:gleznov
    I finally wrote a routine to do it myself.  Thanks for trying though.

    JP
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Course: From Zero to Hero with Nodejs & MongoDB

    Interested in Node.js, but don't know where to start or how to learn it properly? Confused about how the MEAN stack pieces of MongoDB, Expressjs, Angularjs, and Nodejs fit together? Or how it's even possible to run JavaScript outside of the browser?

    Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
    Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
    With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

    846 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    3 Experts available now in Live!

    Get 1:1 Help Now