Click here to Skip to main content
15,895,709 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
My page contains:
1- An asp:treeview nodes (item_Name,item_Id) getting data from database.
2- iframe with a link to an external page with a parameter
The user should select an item (tree node) to populate the iframe source(src) dynamically according to the selected node value (item_id).
the iframe:
ASP.NET
<iframe id="myFrame"  runat="server" 
frameborder="0" marginwidth="0" marginheight="0" border="0" src="http://www.mynextwebsite.com/default.aspx" scrolling="yes"  ></iframe>

I created javascript function to change the iframe src link .. as follows:
setframe() script:

JavaScript
function setFrameUrl(id){
newUrl = 'http://www.mynextwebsite.com/default.aspx?mykey='+ id 
document.getElementById('myFrame').src = newUrl;}

Attribute added to treeview at pageload :

C#
treeView1.Attributes.Add("SelectedNodeChanged","return setFrameUrl('" +treeView1.ClientID + "')");


my problem the <iframe> not changing with a selection!
what is the best way to do it?
Posted
Updated 14-May-12 11:51am
v3
Comments
Steve Echols 15-May-12 0:17am    
Do you get an error in FireBug console? Have you tried to put a break point in setFrameUrl function using FireBug, to see if your function is even being called?
Member 3812793 15-May-12 3:31am    
Yes, for the setFrameUrl()function the firebug said:event is not defined. how to fix that?

1 solution

I think you're confusing dom element events and .net events. SelectedNodeChanged is an asp.net server side event that you can handle when during a postback.

Have a look at this article: ASP.NET TreeView Control & the Client's Browser[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900