Solved

Need Help formatting ASP form

Posted on 2011-03-07
7
192 Views
Last Modified: 2012-06-21
I am just starting out with MS Visual Studio 2010 trying to develop an asp form.  As shown in the code attached, I have 3 text boxes and multiple labels all on a single line.
I want to know how to align the text in the boxes to the RIGHT because they will use numbers.
Also, I included a separate label for each that has one character: *  and I set the property of these as RED. but when I run this code the * are the same color as the rest of the labels.
Any guidance would be helpful.

Thanks, Charlie
<%@ Page Title="Home Page" Language="vb" MasterPageFile="~/Site.Master" AutoEventWireup="false"
    CodeBehind="room_worksheet.aspx.vb" Inherits="room_worksheet._Default" %>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <h2>
        TESCOR, Inc. Room Worksheet</h2>
    <p>
        <asp:Table ID="Table1" runat="server" Width="897px">
        </asp:Table>
    </p>
    <p>
        <asp:Label ID="Label1" runat="server" Text="Exterior Dimensions: "></asp:Label>
        <asp:TextBox ID="txtExt_Width" runat="server" Width="80px"></asp:TextBox>
        <asp:Label ID="Label2" runat="server" Text="Feet Wide"></asp:Label>
        <asp:Label ID="Label3" runat="server" Text="*"></asp:Label>
        <asp:Label ID="Label4" runat="server" Text=" x "></asp:Label>
        <asp:TextBox ID="txtExt_Depth" runat="server" Width="80px"></asp:TextBox>
        <asp:Label ID="Label5" runat="server" Text="Feet Deep"></asp:Label>
        <asp:Label ID="Label6" runat="server" Text="*"></asp:Label>
        <asp:Label ID="Label7" runat="server" Text=" x "></asp:Label>
        <asp:TextBox ID="txtExt_Height" runat="server" Width="80px"></asp:TextBox>
        <asp:Label ID="Label8" runat="server" Text="Feet High"></asp:Label>
        <asp:Label ID="Label9" runat="server" Text="*"></asp:Label>
    </p>
</asp:Content>

Open in new window

0
Comment
Question by:charlieb01
  • 4
  • 3
7 Comments
 
LVL 8

Accepted Solution

by:
PagodNaUtak earned 500 total points
ID: 35064838
try the below code:
<%@ Page Title="Home Page" Language="vb" MasterPageFile="~/Site.Master" AutoEventWireup="false"  
    CodeBehind="room_worksheet.aspx.vb" Inherits="room_worksheet._Default" %>  
  
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">  
</asp:Content>  
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">  
    <h2>  
        TESCOR, Inc. Room Worksheet</h2>  
    <p>  
        <asp:Table ID="Table1" runat="server" Width="897px">  
        </asp:Table>  
    </p>  
    <p>  
        <asp:Label ID="Label1" runat="server" Text="Exterior Dimensions: "></asp:Label>  
        <asp:TextBox ID="txtExt_Width" runat="server" Width="80px" Style="text-align:right;"></asp:TextBox>  
        <asp:Label ID="Label2" runat="server" Text="Feet Wide"></asp:Label>  
        <asp:Label ID="Label3" runat="server" style="color:red;" Text="*"></asp:Label>  
        <asp:Label ID="Label4" runat="server" Text=" x "></asp:Label>  
        <asp:TextBox ID="txtExt_Depth" runat="server" Width="80px"  Style="text-align:right;"></asp:TextBox>  
        <asp:Label ID="Label5" runat="server" Text="Feet Deep"></asp:Label>  
        <asp:Label ID="Label6" runat="server" style="color:red;" Text="*"></asp:Label>  
        <asp:Label ID="Label7" runat="server" Text=" x "></asp:Label>  
        <asp:TextBox ID="txtExt_Height" runat="server" Width="80px"  Style="text-align:right;"></asp:TextBox>  
        <asp:Label ID="Label8" runat="server" Text="Feet High"></asp:Label>  
        <asp:Label ID="Label9" runat="server" style="color:red;" Text="*"></asp:Label>  
    </p>  
</asp:Content>

Open in new window

0
 

Author Comment

by:charlieb01
ID: 35064917
OK, thanks, That worked.
But, before I accept this solution can you tell me if the only way to do this is by hand coding or can this be done by setting properties the way most stuff in Visual Studio is set?
0
 
LVL 8

Expert Comment

by:PagodNaUtak
ID: 35065237
You can change the forecolor of a label by perfroming the code below:

click on the label then right click select properties. On the properties toolbar select forecolor then select your desired color on the list.

But for changing the text alignment is done only in code.




0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 8

Expert Comment

by:PagodNaUtak
ID: 35065253
You can change the forecolor of a label by performing the steps below:


•click on the label then right click select properties. On the properties toolbar select forecolor then select your desired color on the list.



But for changing the text alignment is done only in code.

0
 

Author Comment

by:charlieb01
ID: 35065433
I have tried setting the forecolor property of a label as you describe and it doesn't work. I would expect that following your directions I would see the code change and it does not.
0
 
LVL 8

Expert Comment

by:PagodNaUtak
ID: 35065844
0
 

Author Comment

by:charlieb01
ID: 35068167
I read the article and it says the same thing you described regarding the forecolor property. My only point is, it didn't work like that for me. Changing the forecolor property of a label (even a new on I added as a test) did not change the code nor did it change the output when I ran the page.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

932 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

7 Experts available now in Live!

Get 1:1 Help Now