Treeview Control on click event

E

Ed Dror

Hi there,

Based on Microsoft ASP.NET SDK treeview control binding to northwind
database (Categoried, Products)
I added the following code

Protected Sub TreeView1_SelectedNodeChanged(ByVal sender As Object, ByVal e
As System.EventArgs) Handles TreeView1.SelectedNodeChanged
Me.TreeView1.SelectedNode.NavigateUrl = Me.TreeView1.SelectedNode.Text +
".aspx"
End Sub

For example I added Chai.aspx

Everything works fine when you click on sub menue Chai the Chai.aspx appear
But it dosent appear when you click once you need to click twice on the
treeview control to see the Chai page

My question how to make the treeview control function like binding to
regular xml (sitemap) with one click only
I checked almost 10 other samples of treeview binding to database and all of
them need to click twice on the sub menu

Thanks,
Ed Dror
Email: (e-mail address removed)
 
W

Walter Wang [MSFT]

Hi Ed,

Please note that hyperlink to the target (product) page is rendered to
client and handled by the browser instead of the server-side code; that's
why you only navigate to the target page after you clicked a node second
time: if you hover your mouse cursor on the node the first time, you should
see the navigation target URL is empty then.

Two options to fix this:

1) You can set the NavigateUrl property when binding the Treeview (i.e.,
not set at SelectedNodeChanged event)

2) If option 1) is not possible, you should be able to call
Response.Redirect() in SelectedNodeChanged event to directly instruct the
browser to go to target page.


Let me know if this works or not.


Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
E

Ed Dror

Walter,

Solution 2 works, I replace the code with
Response.Redirect(Me.TreeView1.SelectedNode.Text + ".aspx")

Thanks again
 

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

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top