Click here to Skip to main content
15,881,938 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am working on a simple quiz engine Project .I use to display the Question and Answers in a DetailsView (non editable) and the candidate will be given a dropdownbox to select the correct option .

The datasource of the DetailsView consist of Question id,Question,Answer1,Answer2,Answer3,Answer4,CorrectAnswer from database

When the user select the Option from the dropdown I validate his answer with the correct answer and save it in a datastructure

My issue is that I am not able to hide the correct answer field .ie the candidate will be able to see the correct answer along with the question.If i mark that field as invisible i cannot read the value from that field it will return null here

C#
a.CorrectAnswer = DetailsView1.Rows[5].Cells[1].Text;


Can anyone suggest a better idea for hiding the DetailsView field from user but accessible for code behind
Posted

Don't send it to him!

Just a thought: anything you send to the client, he can see: right click this answer and select "View source" or "view page source" - it varies from browser to browser - and you will see everything that Codeproject sent to you to make this page.
So if you send the "correct answer" to the user as part of the page then he can read it and answer correctly every single time...

Store it in the Session (which doesn't leave the server), or fetch it from your database when you validate his answer in the code behind - but don't send him the answer along with the question!
 
Share this answer
 
Comments
SREENATH GANGA 1-Jun-14 9:39am    
Thanks bro . I accept the Security issue and the chance that the answers will be available to users...but this is just a Kids project and doesn't require more security thats why i choose this option
Set the CssClass to invisible
CssClass="invisible"


and create the ivisible css class:

.invisible {
    display:none;
}
 
Share this answer
 

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