我的Iframe代码 
<iframe src='content.aspx?id=<%=Session["id"] %>'></iframe>
服务器代码 if (Request.QueryString["id"] != null)
{
   Session["id"]= Request.QueryString["id"].ToString();
}
这样做出来,session里面有值 ,但是到content.aspx页面的时候,id 的值就成了:<%=Session["id"] %>服务器根本就没有解析服务器代码。用<%= id %>也是一样的,服务器代码都没有被解析。请问这是什么原因啊?

解决方案 »

  1.   


    为什么要用Session呢?
    <iframe src='content.aspx?id=<%=Session["id"] %>'></iframe>试试这个:)<iframe  src="content.aspx?id=<%=Request.QueryString["id"]%>"></iframe>
      

  2.   

    关键看你这个引用iframe的文件是否是aspx
      

  3.   

    我是在newsshow.aspx里面引用的iframe content.aspx页面,全部都是aspx页面意思就是,从list.aspx 点击链接newsshow.aspx?id=1 转到newsshow.aspx页面,在这个页面接收id=1,然后再iframe content.aspx页面,将id 传给content.aspx页面,然后根据ID在数据库里把相应的新闻查出来,显示在content.aspx页面里面,在页面上看起来,也就是在newsshow.aspx页面上显示新闻。
      

  4.   


    现在的关键问题是  不执行服务器代码,他把<%=%>这个玩意儿,当变量全传给我了!
      

  5.   

    我贴一段我的代码,我都是用这种方式给iframe传值的<table width="100%">
          <tr>
            <td>
              <div id="con">
                <ul id="tagsTab" style="text-align:left;">
                  <li class="selectTag"><a  id="link0" onclick="selectTag('tagContent0',this)" href="#">设备基本信息</a> </li>
                  <li><a id="link1" onclick="selectTag('tagContent1',this)" href="#">3D展示图档</a> </li>
                  <li><a id="link2" onclick="selectTag('tagContent2',this)" href="#">设备主要参数</a> </li>
                  <li><a id="link3" onclick="selectTag('tagContent3',this)" href="#">设备文档</a> </li>
                </ul>
                <div id="tagContent" width="100%">
                  <asp:Panel class="tagContent  selectTag"  style="height:auto;" id="tagContent0" runat="server" Width="100%"> 
                      <iframe id="mainFrame0" frameborder="0"  height="650px"   name="mainFrame0" scrolling="no"
                          src="EQM_EDIT.aspx?mode=<%=Request.QueryString["mode"] %>&id=<%=Request.QueryString["id"] %>&art=<%=Request.QueryString["art"] %>&type=<%=Request.QueryString["type"] %>&pid=<%=Request.QueryString["pid"] %>" width="100%"></iframe>
                  </asp:Panel>
                  <asp:Panel class="tagContent" id="tagContent1" style="height:auto;"  runat="server" Width="100%"> 
                      <iframe id="mainFrame1" frameborder="0" height="650px"  name="mainFrame1" scrolling="auto"
                          src="../3DDoc/3DDoc_Edit.aspx?mode=<%=Request.QueryString["mode"] %>&id=<%=Request.QueryString["id"] %>" width="100%"></iframe>
                  </asp:Panel>
                  <asp:Panel class="tagContent" id="tagContent2" style="height:auto;"  runat="server" Width="100%"> 
                      <iframe id="mainFrame2" frameborder="0" height="650px"  name="mainFrame2" scrolling="no"
                          src="EQM_PARAM_INFO.aspx?mode=<%=Request.QueryString["mode"] %>&id=<%=Request.QueryString["id"] %>" width="100%"></iframe>
                  </asp:Panel>
                  <asp:Panel class="tagContent" id="tagContent3" style="height:auto;"  runat="server" Width="100%"> 
                      <iframe id="mainFrame3" frameborder="0" height="650px"  name="mainFrame3" scrolling="auto"
                          src="../Document/DocumentInfo.aspx?mode=<%=Request.QueryString["mode"] %>&pid=<%=Request.QueryString["id"] %>" width="100%"></iframe>
                  </asp:Panel>
                </div>
            </div>
            </td>
          </tr>
        </table>
      

  6.   

    <iframe id="mainFrame0" frameborder="0"  height="650px"   name="mainFrame0" scrolling="no"
                          src="EQM_EDIT.aspx?mode=<%=Request.QueryString["mode"] %>&id=<%=Request.QueryString["id"] %>&art=<%=Request.QueryString["art"] %>&type=<%=Request.QueryString["type"] %>&pid=<%=Request.QueryString["pid"] %>" width="100%"></iframe>你把src 的 " 换成 '  试一下,有时候这些双、单引号或许也是问题吧。
      

  7.   

    <form id="form1" runat="server"> 
    </form>
    没有放在这里面?
      

  8.   

    我要疯了,他不解析服务器代码。。
    我调试的时候看到request.querystring["id"]的值都是: