Click here to Skip to main content
15,905,558 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
pls how can i create a multiple choice questions page.i want the questions and options to be loaded from an xml file.help me out
Posted
Comments
[no name] 11-Sep-12 22:56pm    
Show us the code for what you have done so far.
Aarti Meswania 12-Sep-12 1:19am    
please set tag for Question, it is related to 'Winform' or 'Webform'.
you have got answer for both.
:)

For WebForms
hi....
u can use datalist for this:

XML
<asp:DataList ID="dl" runat="server">
            <ItemTemplate>
                <table>
                    <tr>
                        <td>
                            <asp:Label ID="lblQues" runat="server" Text="Question" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <asp:RadioButtonList ID="rbtOptions" runat="server">
                                <asp:ListItem Text="Option A" Value="a" />
                                <asp:ListItem Text="Option B" Value="b" />
                                <asp:ListItem Text="Option C" Value="c" />
                                <asp:ListItem Text="Option D" Value="d" />
                            </asp:RadioButtonList>
                        </td>
                    </tr>
                </table>
            </ItemTemplate>
        </asp:DataList>



then u can give datasource of DataList and bind texts and values in "OnItemDataBound" event..
 
Share this answer
 
v2
Comments
Aarti Meswania 12-Sep-12 1:15am    
good answer 5+
Gautam Raithatha 12-Sep-12 1:22am    
thanks aarti..... :)
For WinForms
It will be easy if you go with usercontrol
just create one user-control having label for Question and four radiobuttons for answer

now, just add this user control in form run time

suppose usercontrol name is MyQAControl
now, just add this control in form

Code to add control on form runtime
C#
MyQAControl QA = new MyQAControl(); //create object of control/panel/radiobutton
QA.Dock = Top; //set location using dock or location property
this.Controls.Add(QA); //add control into form so you will able to see that on form


if you want to add radiobuttons & panels saperately without usercontrol then create object of panel same way I have make for 'MyQAControl'.
And you should manage location of control runtime.

Happy Coding!
:)
 
Share this answer
 
v2
Comments
Temidjoy 12-Sep-12 16:07pm    
thanks for your contribution.really appreciate that...
Aarti Meswania 14-Sep-12 0:58am    
welcome :)

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