asp.net center align checkbox - asp.net

Attempting to center align a checkbox, which is displayed using a repeater for each record.
asp:Repeater id="rptSelected" runat="server">
<HeaderTemplate>
<table class="detailstable FadeOutOnEdit">
<tr>
<th style="width:200px;">Contacted</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<th style="width:200px;">
<input type="checkbox" class="AlignCheckBox" name='<%# CallUtilityChangeId((int)Eval("CompanyId")) %>'
<%# SetCheckboxValue((bool)Eval("Contacted"))%> />
</th>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
Using:
.AlignCheckBox
{
text-align: center;
}
but to no avail...any ideas?
thank ye

The css you have there will center align the text within the textbox. In order to align the textbox itself, you need to use that same css but on the texbox's container.
A quick example would be:
th {
text-align: center;
}
As for your exact code, you could get away with this:
<ItemTemplate>
<tr>
<th style="width:200px; text-align: center;">
<input type="checkbox" class="AlignCheckBox" name='<%# CallUtilityChangeId((int)Eval("CompanyId")) %>'
<%# SetCheckboxValue((bool)Eval("Contacted"))%> />
</th>
</tr>
</ItemTemplate>
Adding it to the style tag of your th.

In the ItemTemplate, I think you want "td" tag instead of "th" ;) and add "text-align: center;" to the style attribute:
<ItemTemplate>
<tr>
<td style="width:200px; text-align: center;">
<input type="checkbox" name='<%# CallUtilityChangeId((int)Eval("CompanyId")) %>'
<%# SetCheckboxValue((bool)Eval("Contacted"))%> />
</td>
</tr>
</ItemTemplate>

apply center align on th of checkbox

Related

Internet Exporer 11 rendering table improperly

on my page I have a table with a few elements in it, but it messes up in Internet Explorer 11. Any help appreciated
Here is what it looks like in VS:
In Chrome:
And here IE:
My Code:
<table>
<tr>
<td style="width: 50%; text-align: left"><br /><br /><br />
<asp:Label ID="lbl_dm_rvi" runat="server" Text="sometext RVI"></asp:Label><br />
<asp:Label ID="lbl_dm_odv" runat="server" Text="sometext ODV"></asp:Label>
</td>
<td style="width: 50%; text-align: right; text">
<asp:Label ID="lbl_hochrechnung" runat="server" Text="Hochrechnung_RX_SM_KVBEZ"></asp:Label><br />
<asp:Label ID="lbl_modul1" runat="server" Text="Modul 1"></asp:Label><br />
<asp:Label ID="lbl_modul_30" runat="server" Text="Modul 3.0"></asp:Label><br />
<asp:Label ID="lbl_modul_31" runat="server" Text="Modul 3.1"></asp:Label><br />
<asp:Label ID="lbl_modul3" runat="server" Text="Modul 3"></asp:Label>
</td>
</tr>
<tr>
<td colspan="2">
<img src="klammer.png" style="width: 400px"/>
</td>
</tr>
<tr>
<td colspan="2" style="text-align: center">
<asp:Label ID="lbl_modul2" runat="server" Text="Modul 2"></asp:Label><br />
<asp:Label ID="lbl_odv" runat="server" Text="ODV"></asp:Label><br />
<asp:Label ID="lbl_modul2a" runat="server" Text="Modul 2a"></asp:Label><br />
<asp:Label ID="lbl_modul4" runat="server" Text="Modul 4"></asp:Label><br />
<asp:Label ID="lbl_modul4a" runat="server" Text="Modul 4a"></asp:Label>
</td>
</tr>
</table>
What I see at the first is that the table on IE is take the full width, the other two are not.
This is usually done because its browser did not have the same default setting for all elements.
A quick solution is to set the width on the table as
<table style="width: 300px;" >
so you not left it random.
You can also try to use any "Reset CSS" (like Eric Meyer’s) thats try to bring all browser styles to the same point.
Related: What is the easiest or fastest way to make CSS render the same in all browsers

How to show DIV just on top of button

I have a custom control, which has a Button + image, if image(down arrow) is clicked, a DIV should display, just like Dropdownlist.
However, its pushing the page contents to down to display the DIV. How to fix this.
It should just behave like dropdown
List should display on top of Button instead button
<table id="container" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<asp:Button ID="btnPost" runat="server" CssClass="postButton" OnClick="btnPost_Click" />
<asp:Button ID="btnDropDown" runat="server" CssClass="dropdownButton" OnClick="btnDropDown_Click" />
</td>
</tr>
<tr>
<td>
<div runat="server" id="divDropDownPanel" visible="false" style="text-align: left;
overflow: scroll; float: left; border: thin solid lightgrey; width: 160px; height: 120px;
background-color: #FFFFFF; position: absolute; z-index: 999;">
<asp:Repeater ID="rptDropDownContent" runat="server" OnItemDataBound="rptDropDownContent_ItemDataBound">
<HeaderTemplate>
<table>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td align="left">
<asp:CheckBox ID="chkChannel" runat="server" />
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</tr> </table>
</FooterTemplate>
</asp:Repeater>
<br />
</div>
</td>
</tr>

how to remove space under a table?

Here what I've done and whats my problem. First of all i got a big table with a lot of td the first td on top of my table containt anoter table and (here come my problem) theres a space under that little table and I don't know why.
Here's the code for my table:
<div runat="server" class="ReportPage" >
<table runat="server" class="ListReportBigTable" align="center">
<tr>
<td class="style13" colspan="3" >
<table width="46%" align="center"style="height:50%; "cellpadding="0">
<tr>
<td align="left">
<asp:Label ID="LB_ChooseReport" runat="server"
Text="Choisissez un dossier médical: " Font-Size="Small">
</asp:Label>
</td>
</tr>
<tr>
<td style="vertical-align:bottom" align="left">
<asp:UpdatePanel ID="UpdatePanel3" runat="server">
<ContentTemplate>
<div id="div_Filter" runat="server" visible="false" align="left">
<asp:Label ID="LBL_FilteredBy" runat="server" width="18%" Text="Patient : "
Font-Size="Small" style="margin-left: 0px"></asp:Label>
<asp:DropDownList ID="DDL_FilterSelect" runat="server" AutoPostBack="true"
Width="25%" CssClass="DDL_Filter" Font-Size="Small" Height="18px"></asp:DropDownList>
</div>
</ContentTemplate>
</asp:UpdatePanel></td></tr></table>
<br />
</td>
and here the CSS:
.ListReportBigTable
{
height:25%;
width:55%;
text-align:center;
vertical-align:middle;
border: thick solid black;
margin-left: 0px;
}
thx in advance
I don't know if it's a typo but you are closing with a </td> after your closing </table> tag. In addition you have a <br /> before the closing misplaced </td> which would obviously add space to the bottom.
Try changing the closing </td> to </table></div> and removing the <br />
In addition, in your CSS try adding margin-bottom: 0px; and padding-bottom: 0px; to see if this has an effect.
Also, what is after the table? Maybe whatever is being displayed after the table has it's own top margin/padding?
Do you have a link to the actual page where this is occuring so we can examine with Firebug or similar and try to figure it out?

textboxes alignment messing up when required validators fire?

I have table with couple of textboxes in it. In those 2 fields I have required fields. When validators fire alignment is changing. Before the validators fire, textboxes aligntment is good.
Pic1 for after validator fires.
Pic2 for before validator fires.
Here is the HTML.
<table class="Borderblue" id="Table26" cellspacing="3" align="center" style="width: 100%;">
<tr>
<td bgcolor="White" style="width:20%" >
First Name <br/>
(on website)
</td>
<td bgcolor="White" style="width:20%" >
Middle Intial <br/>
(on website)
</td>
<td bgcolor="White" style="width:20%" >
Last Name <br/>
(on website)
</td>
<td bgcolor="White" style="width:20%" >
Nick Name <br/>
(Goes By Name)
</td>
</tr>
<tr>
<td bgcolor="White" style="width:20%" >
<asp:TextBox ID="txt6_2" runat="server" CssClass="TextBox SmallText" ></asp:TextBox>
<asp:RequiredFieldValidator runat="server" id="RequiredFieldValidator8" ValidationGroup="ValidateInsert" Display="Dynamic" controltovalidate="txt6_2" errormessage="Please enter first name!" />
</td>
<td bgcolor="White" style="width:20%">
<asp:TextBox ID="txt7_2" runat="server" CssClass="TextBox SmallText" MaxLength="2" Width="20px" style="vertical-align:top" ></asp:TextBox>
</td>
<td bgcolor="White" style="width:20%">
<asp:TextBox ID="txt8_2" runat="server" CssClass="TextBox SmallText"></asp:TextBox>
<asp:RequiredFieldValidator runat="server" id="RequiredFieldValidator9" ValidationGroup="ValidateInsert" Display="Dynamic" controltovalidate="txt8_2" errormessage="Please enter last name!" />
</td>
<td bgcolor="White" style="width:20%" >
<asp:TextBox ID="txt9_2" runat="server" CssClass="TextBox SmallText" width="120px"></asp:TextBox> </td>
</tr>
</table>
CSS:
.SmallText
{
font-family: Tahoma, Arial, Helvetica;
text-align:justify;
font-size: 8.5pt;
}
.TextBox
{
Width: 100px;
Height:12px;
background-color:#F0F0F0;
border: 1px solid #000000;
}
You'll probably need to move the validators to their own cells so the text box cells aren't expanded. Or valign="top" on your cells might work.

Aligning label and textbox on same line (left and right)

I have an ASP.NET control. I want to align the textbox to the right and the label to the left.
I have this code so far:
<td colspan="2">
<asp:Label ID="Label6" runat="server" Text="Label"></asp:Label>
<div style="text-align: right">
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
</div>
</td>
The textbox aligns to the right, but the label aligns to the left and on the line above. How can I fix this so that the label is on the left, the textbox on the right, and both on the same line?
Thanks
you can use style
<td colspan="2">
<div style="float:left; width:80px"><asp:Label ID="Label6" runat="server" Text="Label"></asp:Label></div>
<div style="float: right; width:100px">
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
</div>
<div style="clear:both"></div>
</td>
You should use CSS to align the textbox. The reason your code above does not work is because by default a div's width is the same as the container it's in, therefore in your example it is pushed below.
The following would work.
<td colspan="2" class="cell">
<asp:Label ID="Label6" runat="server" Text="Label"></asp:Label>
<asp:TextBox ID="TextBox3" runat="server" CssClass="righttextbox"></asp:TextBox>
</td>
In your CSS file:
.cell
{
text-align:left;
}
.righttextbox
{
float:right;
}
You can do it with a table, like this:
<table width="100%">
<tr>
<td style="width: 50%">Left Text</td>
<td style="width: 50%; text-align: right;">Right Text</td>
</tr>
</table>
Or, you can do it with CSS like this:
<div style="float: left;">
Left text
</div>
<div style="float: right;">
Right text
</div>

Resources