How to prevent changes to CheckBoxList

M

Meerkat

Hello.
Can anyone tell me if there is ANY way to prevent the user changing
the values in a checkboxlist. I just want to use it for information
only. Disabling it is not an option as it results in a unacceptable
gray color.

Many thanks in advance for any replies.
 
D

Duncan Welch

Use a bit of javascript in the onChanged property, and set it back to it's
checked property every time.

D
 
M

Meerkat

Hello Rajesh,

Your suggestion looks to be just the sort of thing I am looking for.
( i.e. simple) However, could I impose on your kindness a little
more and ask exactly where do I put the code that you suggest.
Is it in the code behind or the html? and what is the exact syntax.
I have tried all sorts of things but failed miserably.

Many thanks in anticipation,

Meerkat.
 
R

Rajesh Tiwari

hi meerkat,
sorry for the late reply.here is the code that u were looking for.

run this code and see if it is of some help

<%@ Page Language="c#" debug=true%>
<%@ Import Namespace="System.Data" %>
<Script Language="C#" runat=server>
void Page_Load(Object sender,EventArgs e)
{

lst2.Attributes["onclick"]="javascript:return false";
}
</script>
<html>
<body>
<form id=frm1 runat=server>
<asp:CheckBoxList id=lst2 runat=server>
<asp:ListItem>a</asp:Listitem>
</asp:CheckBoxList>
</form>
</body>
</html>

i hope i answered ur query.

Rajesh
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top