3

我正在创建一个 MCQ 问答界面,我需要将每个单选选项放在答案旁边的单独行中,以便用户可以选择答案,我知道以正常方式在单行中使用单选按钮列表,

 <asp:RadioButtonList ID="opt_questiontype" runat="server" RepeatLayout="Flow" OnClick="call()">
                        <asp:ListItem Value="MCQ" Selected="True">MCQ</asp:ListItem>
                        <asp:ListItem Value="Single">Single Answer</asp:ListItem>
                    </asp:RadioButtonList>

但在这里我需要将它们逐行放置在 html 表中,如下所示,

<table id="mcqtable">
        <tr style="border-bottom-style:solid; border-bottom-width:1px; border-bottom-color:#CCCCCC;">
            <th class="captions2">Option</th><th class="captions2">Answer Text</th><th class="captions2">Is Correct</th>
        </tr>
         <tr>
                <td class="captions1">Answer Option 1</td><td><asp:TextBox ID="txt_answeropt1" runat="server" TextMode="SingleLine" Width="600px"></asp:TextBox></td><td><asp:RadioButton ID="opt_answer1" runat="server" GroupName="grp_answers" Checked="true" /></td>
            </tr>
            <tr>
                <td class="captions1">Answer Option 2</td><td><asp:TextBox ID="txt_answeropt2" runat="server" TextMode="SingleLine" Width="600px"></asp:TextBox></td><td><asp:RadioButton ID="opt_answer2" runat="server" GroupName="grp_answers" /></td>
            </tr>
            <tr>
                <td class="captions1">Answer Option 3</td><td><asp:TextBox ID="txt_answeropt3" runat="server" TextMode="SingleLine" Width="600px"></asp:TextBox></td><td><asp:RadioButton ID="opt_answer3" runat="server" GroupName="grp_answers" /></td>
            </tr>
            <tr>
                <td class="captions1">Answer Option 4</td><td><asp:TextBox ID="txt_answeropt4" runat="server" TextMode="SingleLine" Width="600px"></asp:TextBox></td><td><asp:RadioButton ID="opt_answer4" runat="server" GroupName="grp_answers" /></td>
            </tr>

        </table>

这里我使用了普通的单选按钮,但是在获取选定的值时会发生冲突,所以请任何人都可以提出一种使用asp:RadioButtonList来完成这项任务的方法吗?

4

3 回答 3

0

您应该设置RepeatDirection="Vertical"以按行显示选项。

请参考我的回答@CodeProject -使用 Javascript 或 JQuery 更改 ASP 单选按钮列表重复方向属性,以获取有关我们如何在垂直和水平对齐之间切换的更详细信息。

Demo - [Demo]改变asp RadioButtonList的重复方向

编辑

喜欢下面...

<asp:RadioButtonList ID="opt_questiontype" runat="server" RepeatLayout="Flow" RepeatDirection="Vertical" OnClick="call()">
于 2013-09-10T06:57:36.587 回答
0

要么使用中继器,要么您可以使用 css 为每个单选按钮创建单行。

在中继器中,您可以根据需要控制 HTML

于 2013-09-10T07:07:27.440 回答
0

这里我使用了普通的单选按钮,但是在获取选定的值时会发生冲突

什么是冲突?为什么要在这里使用 RAdioButtonList?您现有的代码没有向我显示任何冲突。

于 2013-09-10T06:52:05.367 回答