|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
disable items in CheckBoxListHi all,
I am using a CheckBoxList control on my aspx page that I bind to an array at runtime. After I databind it, I check two of the items in the CheckBoxList controls. Now I also need to disable these two items so that users can't uncheck them. But I don't know how to disable individual items. Can you please help me achieving this(preferably at runtime)? Thanks in advance. I am sure that this can be improved upon, but here is something that works.
To test the code out (listed below), simply add a CheckBoxList control to a web form (name = "clb") and add the code below to the Page_Load event. When you run the form, there will be 4 items which start out as unchecked. When you click on an item, it will become checked and you will not be able to uncheck it. This should give you a base to work from. HTH, Jody __________________ Dim x() As String = {1, 2, 3, 4} Dim intCount As Integer Dim strItemName As String Dim strScript As String clb.DataSource = x clb.DataBind() For intCount = 0 To x.Length - 1 strItemName = clb.ClientID & "_" & intCount.ToString strScript = "<script language = jscript for =" & strItemName & " event =""onclick"">" & ControlChars.CrLf strScript &= strItemName & ".checked='true';" & ControlChars.CrLf strScript &= " </script> " & ControlChars.CrLf RegisterClientScriptBlock("script" & intCount.ToString, strScript) Next ___________________ Show quoteHide quote "sql" <donotspam@nospaml.com> wrote in message news:ehLpFFeQFHA.2132@TK2MSFTNGP09.phx.gbl... > Hi all, > I am using a CheckBoxList control on my aspx page that I bind to an > array at runtime. After I databind it, I check two of the items in the > CheckBoxList controls. Now I also need to disable these two items so that > users can't uncheck them. But I don't know how to disable individual > items. Can you please help me achieving this(preferably at runtime)? > > Thanks in advance. >
Why use a module instead of class?
An absence of IntelliSense in this situation Writing a little app to modify a file 2d array question... Making trial version Question about Namespaces and the Object Browser. Hierarchal recordset Installing VS.NET 2005 Beta 1 transparancy in vb.net Populating WinForms DataGrid |
|||||||||||||||||||||||