How to prevent changes to CheckBoxList

  • Thread starter Thread starter Meerkat
  • Start date Start date
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.
 
Use a bit of javascript in the onChanged property, and set it back to it's
checked property every time.

D
 
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.
 
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
 
Back
Top