隐藏来自用户的DetailsView feild [英] Hiding the DetailsView feild from user

查看:71
本文介绍了隐藏来自用户的DetailsView feild的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个简单的测验引擎项目。我用来在DetailsView中显示问题和答案(不可编辑),候选人将获得一个下拉框来选择正确的选项。



DetailsView 的数据源包括Question id,Question,Answer1,Answer2,Answer3,Answer4,CorrectAnswer from the database



当用户从下拉列表中选择选项时,我使用正确答案验证他的答案并将其保存在数据结构中



我的问题是我不是能够隐藏正确的答案字段。候选人将能够看到正确的答案以及问题。如果我将该字段标记为不可见,我无法读取该字段中的值,它将在此返回null



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

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





任何人都可以建议从用户隐藏DetailsView字段,但可以访问



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

推荐答案

不要发给他!



只是想一想:你发给客户的任何东西,他都可以看到:右键单击此答案并选择查看源代码或查看页面源代码 - 它随浏览器的不同而不同 - 您将看到Codeproject发送给您的所有内容以构建此页面。

所以如果您将正确答案发送给用户作为页面的一部分然后他可以阅读并每次都正确回答...



将其存储在会话中(它没有离开服务器),或者当你在后面的代码中验证他的答案时从数据库中获取它 - 但是不要把答案和问题一起发给他!
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!


将CssClass设置为不可见

Set the CssClass to invisible
CssClass="invisible"





并创建ivisible css课程:





and create the ivisible css class:

.invisible {
    display:none;
}


这篇关于隐藏来自用户的DetailsView feild的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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