2013-03-12 47 views
1

試圖居中對齊一個複選框,該複選框使用每個記錄的中繼器顯示。asp.net center align複選框

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> 

使用:

.AlignCheckBox 
{ 
    text-align: center; 
} 

,但無濟於事...任何想法?

感謝你們

+0

應用類的'th' – MuhammadHani 2013-03-12 16:18:46

回答

1

你會有居中對齊文本文本框的CSS。爲了對齊文本框本身,您需要使用相同的CSS,但在texbox的容器

一個簡單的例子是:

th { 
    text-align: center; 
} 

至於你確切的代碼,你可以不用它:

<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> 

它添加到您th的風格標籤。

+0

可愛jubbly歡呼二進制 – John 2013-03-12 16:23:58

0

申請中心對齊上個複選框

1

在ItemTemplate,我想你想「TD」的標籤,而不是「日」),並添加「文本對齊:中心;」到樣式屬性:

<ItemTemplate> 
    <tr> 
    <td style="width:200px; text-align: center;"> 
     <input type="checkbox" name='<%# CallUtilityChangeId((int)Eval("CompanyId")) %>' 
     <%# SetCheckboxValue((bool)Eval("Contacted"))%> /> 
    </td> 
    </tr> 
</ItemTemplate> 
+0

好,謝謝 – John 2013-03-12 16:24:36