Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Treeview onselectedindexchange

Reply
Thread Tools

Treeview onselectedindexchange

 
 
Graeme Coutts
Guest
Posts: n/a
 
      02-08-2005
I have a IE Treeview and I am trapping the onselectedindexchange event in a
JavaScript function by:

tree.Attributes.Add("onselectedindexchange",tree.C lientID+"_onchange();");

The JavaScript function simply reads the text of the new selected node and
then writes this to a text field. It looks like:

function tree_tree_onchange()
{
var tree;
var treenode;
tree=document.getElementById('tree_tree');
treenode=tree.getTreeNode(tree.selectedNodeIndex);
document.all.item('tree_text').value=treenode.getA ttribute('Text');
}

Everything is working great except when I re-post the form to the server
(using a separate button control) the selectednodeindex that was set on the
client-side is lost. The tree conttrol returns to the default (first node) as
the selected node.

anyone got a solution for this so that I can retain the client-side
selection?
 
Reply With Quote
 
 
 
 
Mohamed El Ashmawy
Guest
Posts: n/a
 
      02-08-2005
You need to save the changes that you made on the client side and re-apply
them on post on the server side.
Thus, when the tree is rendered again after its post back, it'll be in a
state similar to the one before the postback

Regards
Mohamed El Ashmawy
MEA Developer Support Center
ITWorx on behalf of Microsoft EMEA GTSC

 
Reply With Quote
 
 
 
 
Graeme Coutts
Guest
Posts: n/a
 
      02-08-2005
I dont understand what you mean by 'you need to save the changes'. Im not
making any changes in the client-side - simply reading the selected node text
and writing this to another text field.

""Mohamed El Ashmawy"" wrote:

> You need to save the changes that you made on the client side and re-apply
> them on post on the server side.
> Thus, when the tree is rendered again after its post back, it'll be in a
> state similar to the one before the postback
>
> Regards
> Mohamed El Ashmawy
> MEA Developer Support Center
> ITWorx on behalf of Microsoft EMEA GTSC
>
>

 
Reply With Quote
 
Graeme Coutts
Guest
Posts: n/a
 
      02-08-2005
I found a solution to the problem.

If you are over-ride the events then be sure to queue the base events in
order to maintain the state. At the end of your onselectedindexchange event
add the following lines:

if (event.oldTreeNodeIndex != event.newTreeNodeIndex)
tree.queueEvent('onselectedindexchange', event.oldTreeNodeIndex + ',' +
event.newTreeNodeIndex);

Upon next server re-post the state is preserved.


"Graeme Coutts" wrote:

> I dont understand what you mean by 'you need to save the changes'. Im not
> making any changes in the client-side - simply reading the selected node text
> and writing this to another text field.
>
> ""Mohamed El Ashmawy"" wrote:
>
> > You need to save the changes that you made on the client side and re-apply
> > them on post on the server side.
> > Thus, when the tree is rendered again after its post back, it'll be in a
> > state similar to the one before the postback
> >
> > Regards
> > Mohamed El Ashmawy
> > MEA Developer Support Center
> > ITWorx on behalf of Microsoft EMEA GTSC
> >
> >

 
Reply With Quote
 
Mohamed El Ashmawy
Guest
Posts: n/a
 
      02-17-2005
I am sorry I misunderstood your question.
I thought you meant that you apply some changes on the client side using
javascript code and you would like to persist the changes that you made
upon postbacks.

Congrats for solving the problem
Regards
Mohamed El Ashmawy
MEA Developer Support Center
ITWorx on behalf of Microsoft EMEA GTSC

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DropDownList in a Repeater - OnSelectedIndexChange not firing MattB ASP .Net 2 10-01-2007 08:52 PM
OnSelectedIndexChange runs twice VB Programmer ASP .Net 1 03-22-2006 10:51 PM
drop down list box - client side code won't execute OnSelectedIndexChange ezelasky@hotmail.com ASP .Net 5 12-04-2005 01:31 PM
Get value from datagrid cell OnSelectedIndexChange steve ASP .Net Datagrid Control 0 08-12-2003 08:49 PM
Get value from datagrid DDL cell OnSelectedIndexChange steve roszko ASP .Net 1 08-12-2003 08:46 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57