开发者

How to show a disabled checkbox on a treenode

开发者 https://www.devze.com 2023-02-10 05:11 出处:网络
Im using an asp.net TreeView that is constructed on server side? how can i disable a check box on a tree node开发者_JAVA技巧 but still show it?

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

tks


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


¿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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消