Stop some events from occuring in treeview control

M

Martin

Hi,

I'm usung tree view control in my ASP.Net project.

I have autopostback enabled because I want to take action immediately if the
selected index changes. However I have no interest in other events, like
node expand and collapse, but currently these also cause a postback (to be
expected).

I see that all events are queued regardless of whether autopostback is on -
the notification being delayed until some other button is pressed.

I do not understand how the nodes do expand and collapse immediately on
screen when autopostback is false. I am using an uplevel browser, so expect
DHTML to play a part, but looking at the page source, I don't see it.


Confused.
Martin
 
M

Martin

Okay, I see the DTHML in treeview.htc which is included in the served HTML,
so I understand how expand and collapse happen on the client side.

Now I need to know how to control autopostback more finely - not at the
control level but at the event level.
ie. I don't want autopostback on the expand and collapse events, but I do
want it on the selectedindexchanged event.

Thanks
Martin
 
K

kevinscheidt

First, I see you posted this to quite a few locations. Good job..
hehe.. I would have done the same.

Now, here we go.. This is working for me, but what a @#$)*(#$@()@*
work around:

part 1) Add a Valadation Control, and set it to validate the text of
text box. Set the Textbox to a value of "do not send" and set th
validator to require the value of the Textbox to be "send"... now jus
make the textbox invisible. That takes care of the Autopostback, s
your form will now never submit.. lol...

part 2) here's the really messed up part: for your code for you
treenode... do the following:

nodeLocations.ID = myVarContainingmyCurrentNodeID
nodeLocations.ID &= """ onclick=""treeClick()"

notice the Tripple quotes at the start of the 2nd line? That takes yo
out of the id and into the treenode. Lol then you throw in a onclic
and finish..

you end up with this on the client side:
<tvns:treenode ID="18
onclick="lblLocation.text=this.value;treeClick()">
Upstairs
</tvns:treenode>

Part 3) finally, add a javascript on your form to allow you to chec
what you want and post your form only when you want by setting you
validation field to correct and then submitting. By example, this i
how you would check that there is no children nodes in your selectio
and then submit the form based on that...


function treeClick()
{
var src=window.event.srcElement;
var isFinalNode = src.innerHTML.indexOf('tvns:treenode');
if (isFinalNode==-1){
lblLoginFailures.innerText = 'Final Node';
myvalidationbox.text = "send"
document.forms[0].submit();
}else{
lblLoginFailures.innerText = 'Has Children';
}



-
kevinscheid
 
K

KevinScheidt

First, I see you posted this to quite a few locations. Good job..
hehe.. I would have done the same

Now, here we go.. This is working for me, but what a @#$)*(#$@()@*
work around

part 1) Add a Valadation Control, and set it t
validate the text of a text box. Set the Textbox to a value of "d
not send" and set the validator to require the value of the Textbo
to be "send"... now just make the textbox invisible. That takes car
of the Autopostback, so your form will now never submit.. lol..

[b:8efff0eb5b]part 2)[/b:8efff0eb5b] here's the really messed up
:twisted: part: for your code for your treenode... do th
following

nodeLocations.ID = myVarContainingmyCurrentNodeI
nodeLocations.ID &= """ onclick=""treeClick()

notice the Tripple quotes at the start of the 2nd line? That take
you out of the id and into the treenode. Lol then you throw in
onclick and finish.

you end up with this on the client side
<tvns:treenode ID="18
onclick="lblLocation.text=this.value;treeClick()"
Upstair
</tvns:treenode

[b:8efff0eb5b]Part 3)[/b:8efff0eb5b] finally, add a javascript on you
form to allow you to check what you want and post your form only whe
you want by setting your validation field to correct and the
submitting. By example, this is how you would check that there is n
children nodes in your selection and then submit the form based o
that..

function treeClick(

var src=window.event.srcElement
var isFinalNode = src.innerHTML.indexOf('tvns:treenode')
if (isFinalNode==-1){
lblLoginFailures.innerText = 'Final Node'
myvalidationbox.text = "send
document.forms[0].submit()
}else
lblLoginFailures.innerText = 'Has Children'
 
R

ranjeet_techie

Hi
Martin i am stucked at the same problem.The solution provided in th
forum seems to be of little help.
Can you please help me out.
Regards
Ranjeet :


-
ranjeet_techi
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top