I have a label on an ASP.NET page. Right now, it looks like this:
What I want it to look like is like this:
I've tried using a DIV tag, and I've tried using Style="text-align: right" in the <asp:Label>
tag, neither of which worked. Any suggestions?
EDIT: As per the first comment, this is all inside a table tag:
<asp:Panel ID="Panel2" runat="server" BackColor="#0f6fc6" Height="110px" Width="780px">
<table style="width:780px">
<tr>
<td style="width:90px">
<asp:Label ID="lblFunct" runat="server" Font-Bold="True" Text="Function" ForeColor="White"></asp:Label>
</td>
<td style="width:240px">
<asp:DropDownList ID="ddlFunction" runat="server" AutoPostBack="True" CssClass="textbox" Height="20px" OnSelectedIndexChanged="ddlFunction_SelectedIndexChanged" Width="230px">
</asp:DropDownList>
</td>
<td style="width:120px">
<asp:Label ID="lblRole" runat="server" Font-Bold="True" Text="Role" ForeColor="White"></asp:Label>
</td>
<td style="width:240px">
<asp:DropDownList ID="ddlRole" runat="server" AutoPostBack="True" CssClass="textbox" Height="20px" OnSelectedIndexChanged="ddlRole_SelectedIndexChanged" Width="230px">
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblProd" runat="server" Font-Bold="True" Text="Prod Tasks" ForeColor="White"></asp:Label>
</td>
<td>
<asp:DropDownList ID="ddlTask" runat="server" AutoPostBack="True" CssClass="textbox" Height="20px" OnSelectedIndexChanged="ddlTask_SelectedIndexChanged" Width="230px">
</asp:DropDownList>
</td>
<td>
<asp:Label ID="lblOffprod" runat="server" Font-Bold="True" Text="Off Prod Tasks" ForeColor="White"></asp:Label>
</td>
<td>
<asp:DropDownList ID="ddlOffprod" runat="server" AutoPostBack="True" CssClass="textbox" Height="20px" OnSelectedIndexChanged="ddlOffprod_SelectedIndexChanged" Width="230px">
</asp:DropDownList>
</td>
</tr>
<tr>
<td colspan="2">
<asp:RadioButtonList ID="rblPlatform" runat="server" EnableTheming="True" Font-Size="XX-Small" Height="10px" RepeatColumns="2" Visible="false" Width="270px" ForeColor="White" Font-Bold="True" TextAlign="Left">
<asp:ListItem Selected="True" Value="0">Facets </asp:ListItem>
<asp:ListItem Value="1">Non-Facets</asp:ListItem>
</asp:RadioButtonList>
</td>
<td colspan="2">
<asp:Label ID="lblAccountName" runat="server" Text="Label" ForeColor="White" Visible="true" Style="text-align: right"></asp:Label>
</td>
</tr>
</table>
</asp:Panel>
Try something like this:
<div style="text-align:right">
<asp:Label ID="myLabel" runat="server" Text="Label"></asp:Label>
</div>
You could put the label in a div and in the label tag put style="float:left"
.
<div>
<asp:label ID="myLabel" runat="server" style="float:right"></asp:Label>
</div>
Edit:
Also, for completeness, as mentioned by Aimal Khan you can use it in the code behind as:
myLabel.Attributes.Add("Style", "float: right");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.