title: Passing Parameter From Parent to iframe in C#
body: <p>I have a treeview menu in my Default.aspx page and a set of panels with several controls in Parameters.aspx page. Parameters.aspx is imported to Default in an iframe. Based on the treeNode that the user selects, some panels in Parameters.aspx should either be visible or hidden.eg if the user selects the first node, then panel 4 is hidden but if the user selects second node, all panels are visible.
  (I separated them because Parameters.aspx does a postback which results in a new tab opening every time a treeNode is selected).
  I have tried 
  &lt;
  iframe id="iframe" runat="server" src="Parameters.aspx?Param1=&lt;%=treeview_reportName%>" class="noba" scrolling="no"> </p>
  
  <p>then calling it with querystring
  but I get a variable does not exist error. And when I try passing a session it always returns null when I call it from Parameters.aspx
  All code behind is in C#</p>
  
  <p>This is the Default.aspx:</p>
  
  <pre><code>    &lt;asp:TreeView ID="treeReport" runat="server" DataSourceID="XmlDataSource1" 
                      ImageSet="Arrows" NodeWrap="True" Width="250px" 
                      LeafNodeStyle-NodeSpacing="2.5px" Font-Names="Arial,Helvetica,sans-serif"
                      OnSelectedNodeChanged="treeReport_SelectedNodeChanged"&gt;
                      &lt;DataBindings&gt;
                          &lt;asp:TreeNodeBinding DataMember="ReportTitle" ValueField="Name" 
                              PopulateOnDemand="True" Target="_self"/&gt;
                          &lt;asp:TreeNodeBinding DataMember="ChildReport" ValueField="Value" 
                              PopulateOnDemand="True" Target="_self"/&gt;
                          &lt;asp:TreeNodeBinding DataMember="Reports" ValueField="#Name" Target="_self" /&gt;
                      &lt;/DataBindings&gt;
                      &lt;HoverNodeStyle Font-Underline="True" ForeColor="#5555DD" /&gt;
                      &lt;LeafNodeStyle NodeSpacing="2px" /&gt;
                      &lt;NodeStyle Font-Names="Verdana" Font-Size="8pt" ForeColor="Black" 
                          HorizontalPadding="5px" NodeSpacing="0px" VerticalPadding="0px" /&gt;
                      &lt;RootNodeStyle Font-Bold="True" Font-Size="8pt"/&gt;
                      &lt;ParentNodeStyle Font-Bold="True" /&gt;
                      &lt;SelectedNodeStyle Font-Underline="True" ForeColor="#5555DD" 
                          HorizontalPadding="0px" VerticalPadding="0px" /&gt;
  &lt;/asp:TreeView&gt;
  </code></pre>
  
  <p>The treeview codebehind is </p>
  
  <pre><code>protected void treeReport_SelectedNodeChanged(object sender, EventArgs e)
          {
              string treenodeText = treeReport.SelectedNode.Text;
              string treeview_reportName = "summary";
              switch (treenodeText)
              {
                  case "Overall incident analysis":
                      treeview_reportName = "overall";
                      break;
                  case "All incidents":
                      treeview_reportName = "summary";
                      break;
                  default:
                      treeview_reportName = "overall";
                      break;
              }
  
              Session["ReportGenerate"] = treeview_reportName;
          }
  </code></pre>
  
  <p>And the Parameters.aspx</p>
  
  <pre><code>&lt;asp:Panel ID="pn1" runat="server" Width="610px" Visible="true" CssClass="project-content" &gt;
   //Some controls here
  &lt;/asp:Panel&gt;
  
  &lt;asp:Panel ID="pn2" runat="server" Width="610px" Visible="true" CssClass="project-content" &gt;
   //Some controls here
  &lt;/asp:Panel&gt;
  
  &lt;asp:Panel ID="pn3" runat="server" Width="610px" Visible="true" CssClass="project-content" &gt;
   //Some controls here
  &lt;/asp:Panel&gt;
  
  &lt;asp:Panel ID="pn4" runat="server" Width="610px" Visible="true" CssClass="project-content" &gt;
   //Some controls here
  &lt;/asp:Panel&gt;
  </code></pre>