gpt4 book ai didi

c# - 如何左右对齐控件?

转载 作者:太空宇宙 更新时间:2023-11-03 18:38:51 25 4
gpt4 key购买 nike

我正在使用 ASP.NET 制作动态单选按钮。那里有一个验证控件,我想对齐此单选按钮的一侧。

代码:

<asp:RadioButtonList
ID="tiposeg"
runat="server"
RepeatColumns="3">
<asp:ListItem>a</asp:ListItem>
<asp:ListItem>b/asp:ListItem>
</asp:RadioButtonList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator15"
ControlToValidate="tiposeg"
ErrorMessage='<% # foo.ErrorMessages.EmptyField %>'
runat="server"
/>

问题是:如果使用<asp:RadioButtonList制作, <asp:RequiredFieldValidator显示到下一行,这与我使用“纯 HTML”不同,它显示在控件的一侧(无需使用 CSS)。我希望这是清楚的。提前致谢。

编辑换句话说,可以把 <span>asp:RequiredFieldValidator 生成里面<table><asp:RadioButtonList 生成?

编辑 2

我当前的 ASP.NET 代码;

 <asp:RadioButtonList 
ID="RadioButtonList1"
runat="server"
RepeatColumns="3">
<asp:ListItem>abcd</asp:ListItem>
<asp:ListItem>xyz</asp:ListItem>
</asp:RadioButtonList>

</li>
<li style="display:inline">

<asp:RequiredFieldValidator
ID="ReqiredFieldValidator1"
runat="server"
ControlToValidate="RadioButtonList1"
ErrorMessage="select atleast one radiobutton!"
/>

形式:

我得到的:

enter image description here

我的期望:

enter image description here

最佳答案

您真的要将单选按钮排列在多行多列的网格中吗?如果不是,请删除 RepeatColumns属性并添加 RepeatLayout="Flow"RepeatDirection="Horizontal" :

<asp:RadioButtonList runat="server" ID="RadioButtonList1"
RepeatLayout="Flow" RepeatDirection="Horizontal">

这将呈现不包含 <table> 的单选按钮, 因此验证器将出现在最后一个单选按钮的右侧。

关于c# - 如何左右对齐控件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11366806/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com