Click here to Skip to main content
15,891,253 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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:

ASP.NET
<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>
Posted
Updated 24-Feb-16 21:02pm
v3

1 solution

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.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900