How to automatically send the treenodecheckchanged event of the Treeview back to the server

Source: Internet
Author: User
How to automatically send the treenodecheckchanged event of the Treeview back to the server

ASP. NET
2.0 when the Treeview control is used, the treenode object (Treeview node) with the checkbox control is found. If the checkbox control is selected, the page cannot be sent back. In msdn, there is a comment on the Treeview. treenodecheckchanged event: "When
When the check box of the Treeview control changes the status between two sends to the server, the treenodecheckchanged
Event. This allows you to provide an event processing method, that is, to execute a custom routine (such as updating the database or displaying content) each time this event occurs ). Although treenodecheckchanged
The event is triggered during sending back, but changing the check box does not cause sending back ." The framework itself cannot provide a checkbox sending mechanism.
Although clicking checkbox does not cause sending back,
However, after the page is sent back, the treenodecheckchanged event is processed.CodeIt will be called, that is, if the checkbox click event is captured on the client,
Then use JavaScript to manually send back (dopostback), so that the checkbox can be automatically sent back.
However, when building a tree,
There is no way to define events on treenode, So we add this event to Treeview.
The demo is as follows:

This . Treeviewne. Attributes. Add ( " Onclick " , " Postbackbyobject () " );
This . Treeviewkpi. Attributes. Add ( " Onclick " , " Postbackbyobject () " );

Client step code// Trigger an event when you click the check box
Function Postbackbyobject ()
{
VaR O = Window. event. srcelement;
If (O. tagname = " Input " && O. Type = " Checkbox " )
{
_ Dopostback ("","");
}  
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.