Solved

Need Help formatting ASP form

Posted on 2011-03-07
7
193 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

786 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