DJPB
DJPB

Reputation: 5819

How to show a disabled checkbox on a treenode

Im using an asp.net TreeView that is constructed on server side? how can i disable a check box on a tree node but still show it?

tks

Upvotes: 1

Views: 1977

Answers (3)

arlen
arlen

Reputation: 1065

Call the jQuery function from server side, in your jQuery function disable the checkboxes.

Upvotes: -1

Emanuele
Emanuele

Reputation: 11

¿What about adding an input checkbox to the text of the treenode and set ShowCheckBox = False?

ex:

If NotEnabled Then
  TreeNodeSDM.ShowCheckBox = False
  TreeNodeSDM.SelectAction = TreeNodeSelectAction.None
  Dim cChecked As String = ""
  If bChecked Then cChecked = "checked='checked'"
  TreeNodeSDM.Text = "<input type='checkbox' disabled='disabled' " & cChecked & "><font 
  color='GRAY'>" & TreeNodeSDM.Text & "</font>"
End If

Upvotes: 1

atconway
atconway

Reputation: 21314

Unfortunately there is no way server-side purely that I have seen that will disable the checkboxes once rendered on the client using an ASP.NET TreeView control. One of the better solutions I have seen is to add a className attribute server-side and then scan the checkboxes client-side for the class and disable. This actually is not too bad of a method and it works well.

The className is acting as a flag for client-side code to disable the checkbox. Client side JavaScript can disable the checkbox which is actually just an HTML input.

Have a look at the following example which has the server-side code and client-side JavaScript example on how to do this: Disabling ASP.net treeview checkboxes

Upvotes: 1

Related Questions