Welcome Guest Search | Active Topics | Sign In | Register

Can a TreeView's checkbox fire a server-side event? Options
dmacchia
Posted: Sunday, February 24, 2008 11:14:04 PM
Rank: Member
Groups: Member

Joined: 10/15/2007
Posts: 23
Is there any way that a server-side event can be called when a TreeView's checkbox is checked or unchecked? Right now, I seem to only be able to call an event when the node's item itself is clicked. So that obviously means that the checkbox is seperate from the node itself, correct?

Regards,
David
eo_support
Posted: Monday, February 25, 2008 6:33:28 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi David,

Unfortunately no. Click on the check box are node are handled separately. While you can set clicking a node to trigger a server side event, currently there is no way to set clicking on the checkbox to trigger any event. Sorry about that!

Thanks
dmacchia
Posted: Monday, February 25, 2008 7:29:16 AM
Rank: Member
Groups: Member

Joined: 10/15/2007
Posts: 23
So then, at what point can I tell which nodes have their checkboxes checked? I don't seem to be able to tell at postback or callback. That is, it always shows the state as being unchecked.
eo_support
Posted: Monday, February 25, 2008 7:39:58 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
You can get the value when the page postback. Try the following steps:

1. Place a TreeView in the form;
2. Place a Button in the form;
3. Inside the button's Click handler, check the value of TreeView1.Nodes[0].Checked;
4. Run the page and check the first node of the TreeView, then click the button to postback the page;

You can also check the value on the client side with JavaScript through this function:

http://www.essentialobjects.com/ViewDoc.aspx?t=JSDoc.Public.TreeNode.getCheckState.html

Thanks
dmacchia
Posted: Monday, February 25, 2008 9:26:39 AM
Rank: Member
Groups: Member

Joined: 10/15/2007
Posts: 23
Here is the code that I have and it always seems to show the checkstate as unchecked even the box is checked. This code is placed in the form's submit button click handler:

Code: Visual Basic.NET
For Each node As EO.Web.TreeNode In TreeView1.Nodes
     Select Case node.CheckState
           Case EO.Web.CheckState.Checked
                blah blah blah
           Case EO.Web.CheckState.Indeterminate
                blah blah blah
           Case EO.Web.CheckState.Unchecked
                blah blah blah
     End Select
Next


Any thoughts?
eo_support
Posted: Monday, February 25, 2008 9:29:59 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi David,

Can you try the steps that we posted in our previous post and let us know what happens? Make sure you are running the latest version when you try that.

Thanks
dmacchia
Posted: Monday, February 25, 2008 12:08:07 PM
Rank: Member
Groups: Member

Joined: 10/15/2007
Posts: 23
Nope, I tried the simple steps you listed above and I still get TreeView1.Nodes(0).Checked=False. Here is the HTML:

Code: HTML/ASPX
<eo:TreeView ID="TreeView1" runat="server" ControlSkinID="None" AutoCheckChildren="True" AutoCheckParent="True" AutoUncheckChildren="True">
     <TopGroup Style-CssText="cursor:hand; font-family:Tahoma; font-size:9pt; color:Black; padding-right: 5px; padding-left: 5px; padding-bottom: 5px; padding-top: 5px">
     </TopGroup>
     <LineImages Visible="False" />
     <LookNodes>
          <eo:TreeNode CollapsedImageUrl="00030501" ExpandedImageUrl="00030502" ImageUrl="00030503" ItemID="_Default" NormalStyle-CssText="padding-right: 3px; padding-left: 3px; padding-bottom: 1px; padding-top: 1px" SelectedStyle-CssText="border-right: #8396c3 1px solid; padding-right: 2px; border-top: #8396c3 1px solid; padding-left: 2px; padding-bottom: 0px; border-left: #8396c3 1px solid; padding-top: 0px; border-bottom: #8396c3 1px solid; background-color: #f2f5fb">
               <SubGroup ItemSpacing="4">
               </SubGroup>
          </eo:TreeNode>
     </LookNodes>
</eo:TreeView>


One more thing I forgot to mention is that I have a TreeView1.ItemPopulate event that loads child nodes under each parent node. Would that cause this issue?

By the way, on an entirely different note, how do I know if I have the latest version of the controls? That is, the download page says the current version is "2007.2.34" but the DLL version says "5.0.35.2".
eo_support
Posted: Monday, February 25, 2008 1:27:38 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

It appears that you are dynamically generating the nodes (because your TreeView has no nodes defined), when that is the case, everything is wiped out when you generates the nodes (typically by calling DataBind) again. For example, if you always call DataBind in your Page_Load, whatever changes you made on the client side is instantly gone, because you just told the TreeView to populate from the data source again. The same can occur when you generates nodes from code.

In order to avoid this problem, you should populate from the data source only once. This is typically done by:

Code: Visual Basic.NET
If Not Page.IsPostBack Then 'Without this if everything will be wipped out
    'prepare the data source.....

    TreeView1.DataBind
End If


As for the version number, 2007.2 = 5.0. So you actually have 2007.2.35.2, which is one version ahead because our website was not updated (it is updated now). The last version number ".2" means its for ASP.NET 2.0.

Thanks
dmacchia
Posted: Monday, February 25, 2008 3:34:06 PM
Rank: Member
Groups: Member

Joined: 10/15/2007
Posts: 23
That did it. Thanks for your guidance! Applause

Meanwhile, I'd like to recommend a server-side event for the checkbox in a future release. Pray
eo_support
Posted: Monday, February 25, 2008 3:39:01 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Thanks for the suggestion. We will keep that in mind!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.