如何使复选框在Web应用程序中为只读 [英] how to make Checkbox ReadOnly in Web application

查看:62
本文介绍了如何使复选框在Web应用程序中为只读的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个gridview,每一行都有一个复选框。进入编辑模式时,可以选中/取消选中复选框;但我不希望该复选框在任何其他模式下都可编辑。用户可能会很容易被不反映保存在数据库中的实际值的复选框所迷惑。

I have a gridview with a checkbox in every row. When put into Edit mode the Checkbox can be checked/unchecked; but I don't want the checkbox to be editable in any other mode. The user easily might get confused by checked boxes that do not reflect the real values saved back in the database.

<asp:CheckBox id="checkboxCustomerRequired" runat="server" Checked='<%# Bind("CustomerRequired") %>' Enabled="false" CssClass="Check"/>

我尝试过的可能解决方法:

1)启用设置= false

Possible workarounds I tried:
1) Setting enabled = false

推荐答案

您可以通过返回 false onclick 客户端事件中:

You can make the CheckBox read-only by returning false in the onclick client-side event:

<asp:CheckBox ID="checkboxCustomerRequired" runat="server" onclick="return false;" ... />

这篇关于如何使复选框在Web应用程序中为只读的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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