[英]Radiobutton Text alignment Issue
我在 asp.net 工作並且有單選按鈕列表,我想根據需要對齊它們的文本。 這是我目前擁有的:
我想讓它們像這樣:
編輯:其次,當我單擊 Ages From 單選按鈕時,我會顯示一個 div,如下所示:
當我單擊返回所有年齡單選按鈕時,我想隱藏該 div。 但是 SelectedIndexChanged 第二次及以后都不起作用。 它只在第一次工作。
asp代碼:
<table>
<tr>
<td>
<asp:RadioButtonList ID="rdoAge" runat="server" RepeatDirection="Horizontal"
onselectedindexchanged="rdoAge_SelectedIndexChanged" AutoPostBack="true" >
<asp:ListItem Text="All Ages" Value="All Ages" Selected="True"></asp:ListItem>
<asp:ListItem Text="Ages From" Value="Ages From"></asp:ListItem>
</asp:RadioButtonList>
</td>
<div id="divAge" runat="server" visible="false">
<td>
<asp:TextBox ID="txtAgeFrom" runat="server" CssClass="textEntry2" MaxLength="3" Width="65"></asp:TextBox>
</td>
<td>
<asp:Label ID="lblTo" runat="server" Text="To"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtAgeTo" runat="server" CssClass="textEntry2" MaxLength="3" Width="65"></asp:TextBox>
</td>
</div>
</tr>
</table>
cs文件代碼:
protected void rdoAge_SelectedIndexChanged(object sender, EventArgs e)
{
switch (rdoAge.SelectedValue)
{
case "All Ages":
divAge.Visible = false;
break;
case "Ages From":
divAge.Visible = true;
break;
}
}
如果有人提出對這個問題有用的東西,我將不勝感激。
提前致謝。
那是缺少結束標簽的問題。 我一定錯過了某個控件的結束標記。 我重新添加了所有控件來處理結束標簽。 現在它工作正常。
感謝大家的幫助。
嘗試使用 css sytel
<style type="text/css">
table.radioWithProperWrap input
{
float: left;
}
table.radioWithProperWrap label
{
word-wrap: break-word;
}
</style>
<asp:RadioButtonList runat="server" CssClass="radioWithProperWrap" ....>
switch (rdoAge.SelectedItem.Text)
在源代碼中,像這樣定義更新面板:
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
然后在 OnSelectedIndexChanged 事件中,添加 UpdatePanel1.Update();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.