Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Need Help formatting ASP form

Posted on 2011-03-07
7
Medium Priority
?
200 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 2000 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

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 …
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…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Screencast - Getting to Know the Pipeline

916 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