Event checking treeview changes not working
I am working with a control Treeview
and I am using the following code
<asp:TreeView ID="tvCategories" ShowCheckBox="False" Style="font-family: Trebuchet MS;
margin-top: 5px; margin-bottom: 5px; margin-left: 20px; color: Black; font-size: 12px"
runat="server" ShowLines="true" NodeIndent="5" OnTreeNodeCheckChanged="tvCategories_TreeNodeCheckChanged"
OnSelectedNodeChanged="tvCategories_SelectedNodeChanged">
<LeafNodeStyle ForeColor="#555555" />
<ParentNodeStyle ForeColor="Black" />
<RootNodeStyle ForeColor="Black" />
</asp:TreeView>
Both OnTreeNodeCheckChanged
and OnSelectedNodeChanged
are not working, and the property AutoPostBack
is not available for Treeview
.
Please help me with this problem. thank
source to share
There is no property for TreeView AutoPostBack
.
According to MSDN :
The event is TreeNodeCheckChanged
raised when a checkbox in a control TreeView
changes state between messages on the server. This allows you to provide an event-handling method that executes a custom procedure, such as updating a database or displaying content, whenever this event occurs.
You can try javascript to post back the page by adding an onclick event.
source to share
You need to use javascript to do the postback of the page, after which the treenodechechchanged event can be fired.
as shown below, you should add bolder code to make the postback page:
<script language="javascript" type="text/javascript">
function postBack()
{
var element = window.event.srcElement;
if (element .tagName == "INPUT" && element.type == "checkbox")
{
__doPostBack("","");
}
}
</script>
Add the above javascript code to the chapter section of the page.
onclick="javascript:postBack()"
source to share