|
Rank: Newbie Groups: Member
Joined: 6/1/2010 Posts: 1
|
Hi, I've this problem: I've a TreeView with checkbox with: RaisesServerEvent ="True" and OnItemCheckStateChanged="MyEventHandler"
In codebhind I have protected void MyEventHandler(object sender, TreeNodeCheckStateChangedEventArgs e) { ..... }
So the event OnItemCheckStateChanged Never fire (if I click an Item without check it, the page postback regulary).
I Wish to postback any time I check/uncheck the checkboxes in the treeview items, so, server side can handle the event ClientSideOnCheckStateChanging. Any idea?
Thanks in advanced Gianluca.
This is my code: <eo:TreeView ID="TreeViewGroups" runat="server" AllowDragDrop="false" ClientSideOnCheckStateChanging="TreeViewGroupsCheckChanged" OnItemClick="TreeViewGroups_OnItemClick" RaisesServerEvent ="True" AllowDragReordering="false" Width="400px" AutoCheckChildren = "false" DataSourceID ="XmlDataSourceGroups" OnItemCheckStateChanged ="TreeViewGroups_OnCheckChanged" OnPreRender ="TreeViewGroups_OnPreRender" ToolTip ="Struttura espositiva dei gruppi utenti dell'Ente" AllowEdit="false" AutoScroll="False" > <LookNodes> <eo:TreeNode ItemID="_Default" CollapsedImageUrl="~/images/GroupsContainer.gif" ExpandedImageUrl="~/images/GroupsContainer.gif" ImageUrl="~/images/group.gif" SelectedStyle-CssClass="TreeViewMenuSelectedItem" NormalStyle-CssClass="TreeViewMenuNormalItem" DisabledStyle-CssClass="TreeViewMenuDisabledItem"> </eo:TreeNode> </LookNodes> <TopGroup Style-CssClass="TreeViewMenuTopGroup"> <Bindings> <eo:DataBinding Property="Text" DataField="@text" > </eo:DataBinding> <eo:DataBinding Property="Value" DataField="@page"> </eo:DataBinding> <eo:DataBinding Property="TargetWindow" DataField="@targetoptions"> </eo:DataBinding> </Bindings> </TopGroup> <CheckBoxImages Visible="True" Margin="3"></CheckBoxImages> </eo:TreeView>
ANd codebehind protected void TreeViewGroups_OnCheckChanged(object sender, TreeNodeCheckStateChangedEventArgs e) { .... }
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi, The event is not fired immediately. It's a delayed event similar to a TextBox's Change event, which is not fired when you type in the textbox but is fired after the page posts back. In your case you can add additional code to handle the TreeView's ClientSideOnCheckStateChanging and delay triggering a post back from there. It will be something like this:
Code: HTML/ASPX
<eo:TreeView ClientSideOnCheckStateChanging="check_state_changing" ....>
.....
</eo:TreeView>
Code: JavaScript
function check_state_changing()
{
....delay triggering a post back
}
Please see this post for details about how to delay trigger a post back: http://www.essentialobjects.com/forum/postst4619_how-to-implement-auto-postback-for-grid.aspxThis will immediately trigger a post back when user check/uncheck a node. Once post back occurs, your original OnItemCheckStateChanged will be fired. Hope this helps. Please feel free to let us know if you still have any questions. Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 6/3/2010 Posts: 2
|
Hi, I've tried your solution, but after the postback caused by the javascript __DoPostback(), the event OnItemCheckStateChanged is not fired. The event OnItemCheckStateChanged is fired only if: - I remove the ClientSideOnCheckStateChanging - I add the OnItemClick handler - I check the checkbox and then click the item. In this case, the click on the item cause the postback anche the event OnItemCheckStateChanged and OnItemClick are fired both. Any idea? Thanks in advanced. Gianluca.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
You must delay your __doPostBack with a timer. If the problem continues, please isolate the problem into a test page and post the full test page. We will run it here and see what we can find.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 6/3/2010 Posts: 2
|
Problem solved! Thank you very mutch.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Glad that it works for you. Thanks for the update!
|
|