How do you reference a control from another aspx page?

I have a treeview web control on a aspx frame page (menu.aspx).   When the user clicks on a node on the treeview, the main frame (in the center of the page) navigates to the appropriate page.   From this page (main.aspx) I need to know the selected node index from the control located on the menu page.  How do I reference this control?

I may be going about this wrong any insight would be helpful.

Originally I tried this...

Here is how the node is structured....

<asp:treenode name="product" navigateurl=".\\main.aspx"/>


SelectedNodeChanged event occurs....(when the user clicks a node in the treeview control)
Call class main.displaynodedata(myTree.nodes.selectedindex(selectednode).text) // syntax is probably wrong here...dont have the code in front of me.

When main.displaynodedata is called in main.cs it looks like this...


public void displaynodedata(string id)


When the node is should navigate to the page (navigateurl) .....but my code executes first so the page hasnt load.

please help.  :)

thanks everyone


Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

on the selected index changed event u navigate to the main page and pass whatever u want as querystring (probably id of the node)

JohnnyKnoxvilleAuthor Commented:
can you give me an example of the best way to do this?

thanks again..

JohnnyKnoxvilleAuthor Commented:
How do you navigate to another page?  I only know how to add the NavigateUrl to the treenode.  
OWASP: Forgery and Phishing

Learn the techniques to avoid forgery and phishing attacks and the types of attacks an application or network may face.

JohnnyKnoxvilleAuthor Commented:
Ok...I found Context.Items  which contains a hashtable of key value pairs.    But I still have an issue,

I have a menu frame and a main frame.  When an item is clicked on the tree node in the menu frame...I need to do a server.transfer to the main frame.   How do I specify a target?

JohnnyKnoxvilleAuthor Commented:
It doesnt look like I can specify a target using server.transfer.

Im still navigating using the NavigateUrl property of the treenode.

When a node is clicked...It loads the page using the 'main' target.  (executes page_load)  

At this point txtName is a System.UI.WebControls.Textbox.

Then the SelectedIndexChanged event occurs on the Menu frame.

private void trvPST_SelectedIndexChange(object sender, Microsoft.Web.UI.WebControls.TreeViewSelectEventArgs e)
      string nodename = trvPST.GetNodeFromIndex(trvPST.SelectedNodeIndex).Text;
      string parentname = trvPST.GetNodeFromIndex(trvPST.SelectedNodeIndex).Parent.ToString();
      case "ProductFamily":
             PSTGeneral pst = new PSTGeneral();

This passes the name of the node to a method in PSTGeneral.aspx.   But when the code steps in...the textbox is now <undefined value>

public class PSTGeneral : System.Web.UI.Page
            protected Microsoft.Web.UI.WebControls.TabStrip tsContent;
            protected System.Web.UI.WebControls.Label lblName;
            public System.Web.UI.WebControls.TextBox txtName;

public void DisplayGeneralData(string id)
      string s = string.Empty;
      s = id;                  
      txtName.Text = s;   //Textbox is undefined HERE!!!!!!!!!

If someone can please tell me the flow of and how I am supposed to pass data between frames.....I would REALLY appreciate it.  


do one thing
end of trvPST_SelectedIndexChange function add few more line of code

response.write("<script>'mainframename.src="mainpage.aspx?id=" + idofnode + "'</script>")

from the mainpage u can access the id using id = request.querystring("id")

check for the syntax errors javascript is case sensitive

mainframname is the framename which u want the mainpage to be loaded .idofnode is the value u want to pass to other page
JohnnyKnoxvilleAuthor Commented:
Sorry...Im brand spankin new.

Do I put both of these in the client side scripts?

Im doing this as of right now..


function trvPST_SelectedIndexChange()
response.write("<script>'main.src="MyPage.aspx?id=" + trvPST.GetNodeFromIndex(trvPST.SelectedNodeIndex).Text + "'</script>")
<body MS_POSITIONING="GridLayout" BGCOLOR="#f0f1f3">
<form id="frmPstMenu" runat="server">
      <iewc:treeview id="trvPST" onselectedindexchange="SelectedIndexChange()" style="Z-INDEX: 101; LEFT: 1px; POSITION: absolute; TOP: -2px" runat="server" Height="100%" Width="100%" autopostback="true" BackColor="#F0F1F3"></iewc:treeview>


<script language=javascript>
function GetId()
      id = Request.QueryString("id");

<body MS_POSITIONING="GridLayout" onload="GetId()">

I get errors because Request is undefined.

Is .NET really this difficult?  Or am I just making it this difficult?    :)

<script language=javascript>
function GetId()
     id = <% =Request.QueryString("id") %>;

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.