Click here to Skip to main content
13,298,481 members (66,751 online)
Click here to Skip to main content
Add your own
alternative version


2 bookmarked
Posted 7 Mar 2011

Load page in IFRAME based on TreeView node selection

, 8 Mar 2011
Rate this:
Please Sign up or sign in to vote.
Load page in IFRAME based on TreeView node selection without postback.
This is helpful when you are using TreeView and IFRAME and you want to load a page in IFRAME according to selected value from TreeView.

<asp:TreeView ID="TreeView1" class="leftpaneltree" runat="server" ImageSet="Arrows"
                                        NodeIndent="7" ExpandDepth="0">
                                        <HoverNodeStyle Font-Underline="True" ForeColor="#5555DD" />
                                            <asp:TreeNode Text="User" Value="User" NavigateUrl="User/Users.aspx"
                                                <asp:TreeNode Text="Admin" Value="Admin" NavigateUrl="User/Admin.aspx">
                                                <asp:TreeNode Text="User" Value="User" NavigateUrl="User/User.aspx">
                                            <asp:TreeNode NavigateUrl="Department/Department.aspx" Text="Department"
                                                <asp:TreeNode NavigateUrl="Department/Sales.aspx" Text="Sales"
                                                <asp:TreeNode NavigateUrl="Department/Purchase.aspx" Text="Purchase"
                                                <asp:TreeNode NavigateUrl="Department/Marketing.aspx" Text="Marketing"
                                        <NodeStyle Font-Names="Tahoma" Font-Size="10pt" ForeColor="Black" HorizontalPadding="2px"
                                            NodeSpacing="0px" VerticalPadding="0px" />
                                        <ParentNodeStyle Font-Bold="False" />
                                        <SelectedNodeStyle Font-Underline="True" ForeColor="#5555DD" HorizontalPadding="0px"
                                            VerticalPadding="0px" />
 <script language="javascript" type="text/javascript">
        function assignTreeNodeEvent() {
            var tree = document.getElementById('<%=TreeView1.ClientID %>');
            var nodes = tree.getElementsByTagName('a');
            for (var n = 0; n < nodes.length; n++) {
                var url = nodes[n].getAttribute('href');
                if (url.indexOf(".aspx") > 3) {
                    nodes[n].setAttribute('href', '#');
                    var strclick = "changePage('" + url + "')";
                    nodes[n].setAttribute('onclick', strclick);
        function changePage(sTargetPage) {
            var frmPage = document.getElementById('iframeName');
            frmPage.src = sTargetPage;


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


About the Author

Sunasara Imdadhusen
Software Developer (Senior) Infostretch Ahmedabad-Gujarat
India India
Aspiring for a challenging carrier wherein I can learn, grow, expand and share my existing knowledge in meaningful and coherent way.

sunaSaRa Imdadhusen


  1. 2nd Best Mobile Article of January 2015
  2. 3rd Best Web Dev Article of May 2014
  3. 2nd Best Asp.Net article of MAY 2011
  4. 1st Best Asp.Net article of SEP 2010

Read More Articles...

You may also be interested in...

Comments and Discussions

QuestionMy Sharepoint sample Pin
Kamalnath98216-Mar-15 13:41
memberKamalnath98216-Mar-15 13:41 
GeneralHi! thank you. But a question. This part no found in IE. ... Pin
fense9-Feb-12 10:03
memberfense9-Feb-12 10:03 
GeneralRe: Hi! thank you.But a question.This part no found in IE.... Pin
Sunasara Imdadhusen22-Apr-14 4:52
professionalSunasara Imdadhusen22-Apr-14 4:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.171207.1 | Last Updated 8 Mar 2011
Article Copyright 2011 by Sunasara Imdadhusen
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid