asp.net - 如何在单选按钮列表中添加复选框元素
问题描述
我的代码看起来像这样:
<asp:RadioButtonList>
<asp:ListItem></asp:ListItem>
<asp:ListItem></asp:ListItem> //ToDo
<asp:ListItem></asp:ListItem>
</asp:RadioButtonList>
我想<asp:CheckBox>
在选择第二个列表项后显示元素。因此,复选框需要出现在第二个和第三个列表项之间。有没有办法做到这一点?现在我在单选按钮列表元素之后显示复选框。
解决方案
这是不可能的RadioButtonList
。您将不得不使用单个 RadioButtonsGroupName
来创建您自己的。
<asp:RadioButton ID="RadioButton1" runat="server" GroupName="MyGroup" />
<asp:CheckBox ID="CheckBox1" runat="server" />
<asp:RadioButton ID="RadioButton2" runat="server" GroupName="MyGroup" />
<asp:RadioButton ID="RadioButton3" runat="server" GroupName="MyGroup" />
更新
这有点可能以一种骇人听闻的方式。如果它有用取决于你想用那个复选框做什么。使Text
ListItem 的 html 复选框。
RadioButtonList1.Items[1].Text = "<input type=\"checkbox\" id=\"checkBoxInsideList\" class=\"RadioButtonListWithCheckbox\">";
然后将其移到单选按钮上
<style>
.RadioButtonListWithCheckbox {
margin-left: -16px;
}
</style>
推荐阅读
- python - 不能将序列乘以“浮点”Python 类型的非整数
- javascript - 第一次选择后,模式功能不会在单选按钮更改时触发
- javascript - 在测试函数之外没有调用 Jest 模拟实现
- c# - 如何在 C# 中实现增量时间
- cmake - 具有多个组件的基本项目设置
- python - 在 python 中使用 np.where 函数时如何避免 NaN?
- javascript - 如何使用 map 返回嵌套对象?
- javascript - 获取 Web 组件内的事件目标
- python - Matplotlib - 保存没有任何空白或网格线可见的图像
- jquery - 更改 Kendo UI 用于 jQuery 的时区