Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET VB.NET
I need help on how to code, for an explain the answer to a question in an Online Examination project. want to code to work when you click a button named "explain", the explanation of the question and its answer will appear on the same page as the question. Please suggestions and links will be appreciated. Thank you.
Posted 28-Mar-13 2:15am
Edited 28-Mar-13 2:20am
v3
Comments
aspnet_regiis -i at 28-Mar-13 7:17am
   
okk
ryanb31 at 28-Mar-13 7:22am
   
Where are you stuck?
Hariharan Arunachalam at 28-Mar-13 7:22am
   
Have the explanations stored in a database as text/string.
Have a display field; use AJAX to get the explanations when required or use plain show/hide using javascript. Populate the explanations into the fields when rendering the page to the client. And you're done!!!
OsoJames at 28-Mar-13 7:27am
   
@ryanb31, i just had the idea but had no idea to go about.
@Hariharan, thanks for the idea i'll try it, it sounds good.
@aspnet_regiis -i, any suggestions or links. I need more options
Ankur\m/ at 28-Mar-13 8:02am
   
So did you do any basic research or searched Google for information on the subject?
OsoJames at 28-Mar-13 8:10am
   
@Ankur\m/, yes i did

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You can done this using two ways..
 
1. Using code behing
Just load explanation of the question in panel for each questions and set visibility="false".. When user clicks on explain button set panel visibility="true"..
Example :
Html below..
<div>
        Question 1. what is object..?
        <br />
        Answer : Object is a instance of class
        <br />
        <asp:Button ID="Button1" runat="server" Text="explain" />
           <br />
        <asp:Panel ID="panel1" Visible="false" runat="server">
            A class or struct definition is like a blueprint that specifies what the type can
            do. An object is basically a block of memory that has been allocated and configured
            according to the blueprint. A program may create many objects of the same class.
            dynamically.
        </asp:Panel>
    </div>
 
Code behind..
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        If panel1.Visible = True Then
            panel1.Visible = False
            Button1.Text = "explain"
        Else
            panel1.Visible = True
            Button1.Text = "Hide"
        End If
 
    End Sub
 

2. Using JQuery
script below..
<script src="js/jquery-1.4.2.js" type="text/javascript"></script>
   <script type="text/javascript">
   $(document).ready(function()
   {
       $("#div1").hide();
       $("#Button1").click(function()
       {
           $("#div1").toggle();
       });
   });
   </script>
Html below..
<div>
        Question 1. what is object..?
        <br />
        Answer : Object is a instance of class
        <br />
        <input id="Button1" type="button" value="explain" />
           <br />
        <div id="div1">
            A class or struct definition is like a blueprint that specifies what the type can
            do. An object is basically a block of memory that has been allocated and configured
            according to the blueprint. A program may create many objects of the same class.
        </div>
    </div>
See below link..
http://www.electrictoolbox.com/show-hide-element-with-jquery-part-1/[^]
  Permalink  
Comments
OsoJames at 28-Mar-13 8:11am
   
Thank you very much vinodkumarnie for the help, i guess it would work perfectly
vinodkumarnie at 28-Mar-13 8:21am
   
Welcome.. Please have practice of giving rates and accepting answers if you got answer..
OsoJames at 28-Mar-13 10:24am
   
Thanks, its working just perfectly, i needed the idea, so i could apply it to the 'explain value' i retrieve from my database. Thanks for the advice
vinodkumarnie at 28-Mar-13 11:26am
   
You are most welcome... :-)

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

  Print Answers RSS
0 OriginalGriff 539
1 Maciej Los 300
2 DamithSL 233
3 Sergey Alexandrovich Kryukov 209
4 BillWoodruff 200
0 OriginalGriff 7,168
1 Sergey Alexandrovich Kryukov 6,377
2 DamithSL 5,461
3 Manas Bhardwaj 4,876
4 Maciej Los 4,450


Advertise | Privacy | Mobile
Web01 | 2.8.1411023.1 | Last Updated 28 Mar 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100