创建可以切换问题的面板 [英] Create panel in which questions can be switched

查看:82
本文介绍了创建可以切换问题的面板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要创建一个随机生成的面板,因为总体上没有任何问题可以改变,并且在面板中学生可以切换到问题,如果回答其颜色变为绿色,则查看并且没有回答,然后颜色变为橙色,如果没有查看是由默认颜色定义的。

请建议我如何处理这个概念,

因为我厌倦了创建单个按钮,但这很复杂,因为问题的数量也在变化。



我尝试了什么:



I want to create a panel which is generated randomly as total no of questions can change, and in panel student can switch to question , if answered its color changes to green is viewed and not answered then color changes to orange and if not viewed is defined by default color.
Please suggest me how to approach on this concept,
as i tired creating individual button , but that is complicating as number of questions are also changing.

What I have tried:

<div id="swtchPanel" style="width: 100%; height: 250px; margin-removed 50px;">
                    <div style="width: 30%; float: left; margin-removed 9%; padding: 5%;">
                        <asp:Button ID="Button1" runat="server" Text="1" class="switchbutton" OnClick="Button1_Click" />
                    </div>
                    <div style="width: 30%; float: left; margin-removed 9%; padding: 5%;">
                        <asp:Button ID="Button2" runat="server" Text="2" class="switchbutton" OnClick="Button2_Click" />
                    </div>
                    <div style="width: 30%; float: left; margin-removed 9%; padding: 5%;">
                        <asp:Button ID="Button3" runat="server" Text="3" class="switchbutton" OnClick="Button3_Click" />
                    </div>
                    <div style="width: 30%; float: left; margin-removed 9%; padding: 5%;">
                        <asp:Button ID="Button4" runat="server" Text="4" class="switchbutton" OnClick="Button4_Click" />
                    </div>
                    <div style="width: 30%; float: left; margin-removed 9%; padding: 5%;">
                        <asp:Button ID="Button5" runat="server" Text="5" class="switchbutton" OnClick="Button5_Click" />
                    </div>
                    <div style="width: 30%; float: left; margin-removed 9%; padding: 5%;">
                        <asp:Button ID="Button6" runat="server" Text="6" class="switchbutton" OnClick="Button6_Click" />
                    </div>
                    <div style="width: 30%; float: left; margin-removed 9%; padding: 5%;">
                        <asp:Button ID="Button7" runat="server" Text="7" class="switchbutton" OnClick="Button7_Click" />
                    </div>
                    <div style="width: 30%; float: left; margin-removed 9%; padding: 5%;">
                        <asp:Button ID="Button8" runat="server" Text="8" class="switchbutton" OnClick="Button8_Click" />
                    </div>
                    <div style="width: 30%; float: left; margin-removed 9%; padding: 5%;">
                        <asp:Button ID="Button9" runat="server" Text="9" class="switchbutton" OnClick="Button9_Click" />
                    </div>
                    <div style="width: 30%; float: left; margin-removed 9%; padding: 5%;">
                        <asp:Button ID="Button10" runat="server" Text="10" class="switchbutton" OnClick="Button10_Click" />
                    </div>
                </div>

推荐答案

您需要动态创建控件。您可以使用 Label RadioButtonList 创建用户控件。 标签可用于显示问题文本, RadioButtonList 可供用户回答。



您也可以使用保存按钮,以便用户可以提交该问题的答案。恕我直言,页面末尾应该有一个保存按钮而不是每个问题一个保存。



当你从数据库中得到问题时,每个问题创建一个控件在页面上。



默认情况下,控件将具有默认颜色。当用户从列表中选择一个选项时,您可以通过javascript更改问题的颜色。



既然你提到观看也会改变颜色,我会假设你让用户点击某些东西来查看问题。恕我直言,我不会这样。为什么要让用户多次点击才能看到问题。
You will need to create the controls dynamically. You can create a user control with a Label and a RadioButtonList. Label can be used to display the question text and RadioButtonList for users can answer.

You may also use a save button so that user can submit the answer to that question. IMHO there should be a save button in the end of page rather than one save per question.

When the you get the questions from the database, create one control per question on the page.

By default the controls will have default color. When the user selects an option from the list, through javascript you can alter the color for the question.

Since you have mentioned viewing would also change color, I would assume you are making users click on something to view the question. IMHO, I would not have this. Why do want to make users click multiple times to see the question.


这篇关于创建可以切换问题的面板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆