<form id="Form1" method="post" runat="server">    <asp:TextBox id="txbTitle" runat="server"></asp:TextBox>   <asp:Button id="btnSearch" runat="server" Text="Go!" ></asp:Button></form>网页右边是一个Iframe name="Right" 怎样让TextBox的内容传给Search.aspx,再在Iframe中显示搜索结果???

解决方案 »

  1.   

    方法很多!说个常用的!
    public static string search;
    search = txbTitle.Text;if(search != null){
       xxx=select * from xxx where xxx='"+search+"';
    }
      

  2.   

    啊哦,忘记你右面是Iframe 了!
      

  3.   

    用Session传也可以的.我项目中的就是用Session传的.用URL来判断是来自那个页面.
      

  4.   

    在后台对按钮做事件
    btnSearch.Attributes.Add("onclick","document.all('Right').src='xxx.aspx?txbTitle=" + document.all('txbTitle').value + "';return(flase);");
    这样,当点击的时候,此页面并不会提交,并且,你的iframe的Src页面,将重新改变,并且获取当前页面中的输入框的值.此时,你在此iframe所指向的页面中如下取值
    xxx.aspx
    string txbTitle = this.Request.QueryString["txbTitle"]
    即可取到传递来的值.
      

  5.   

    hchxxzx(NET?摸到一点门槛) 的就可以
      

  6.   

    我要问的就是怎么把值传到Iframe中,asp.net中的action是默认本页的,加了
    <form runat="server" onsubmit="this.action='xxx.aspx';">
    在xxx.aspx中Request.Form来获取数据
    这个不能解决xxx.aspx显示在Iframe中用Response.Redirect又没有Target的属性,我还能怎么做?
      

  7.   

    请问hchxxzx(NET?摸到一点门槛) :
    这一句加在哪?
    btnSearch.Attributes.Add("onclick","document.all('Right').src='xxx.aspx?txbTitle=" + document.all('txbTitle').value + "';return(flase);");
    加在Page_Load中为什么说字符文本中字符太多。
      

  8.   

    我有个比较苯的办法,就是用客户端Javascript传递。
     以下是实现方法    框架网页之间的表单的文本框之间数据传递.
            注意的地方是框架的写法:<frameset cols="505,505">
      <frame src="test.htm" name="leftr" id="leftr">//定义框架的名称
      <frame src="test2.htm" id="right" name="right">
    </frameset>
    <noframes><body></body></noframes>
    具体的实现代码如下:
    <script language="JavaScript">
    function ok()
    {
      parent.leftr.document.form2.textfield2.value=document.form1.textfield.value
    }
    </script>不过 我想ASP。net 肯定会提供一套自己的解决办法。我这个想法可能有点另类。
      

  9.   

    我也在同时做一个搜索页面,和你遇到一样的问题
    <frameset border="0" rows="30%,*" framespacing="0" frameBorder="0" id="frame">


    <frame name="top" src="QueryThesis.aspx" >
    <frame name="main" src="ThesisResult.aspx">

    </frameset>
    采用的是url传值,在ThesisResult.aspx中接收,但打开划分页的时候,上面的ftame是正常显示的,但下面的就是缺少参数,象string txbTitle = this.Request.QueryString["txbTitle"]
    ,接受不到,就抱错,应该怎么样解决啊?楼住,借宝地一问,共同学习哈!
      

  10.   

    Response.Write("<script language=\"javascript\">window.parent.frames(\"mainFrame\").document.location.href =\"searchresults.aspx?type="+index+"&fullType="+indexText+"&abc="+Server.UrlEncode(searchTxt)+"\";</script>");请注意用Server.UrlEncode解码.不然传不过去
    mainFrame为框架名
      

  11.   

    我用的是一个Iframe,方法一样吗?To: wingnal(清淡天和) ,给点提示啊?hchxxzx(NET?摸到一点门槛):改如下看看
    btnSearch.Attributes.Add("onclick","document.all('Right').src='xxx.aspx?txbTitle=" + document.all.txbTitle.value + "';return(flase);"); 
    ----------------------------------------------------------------
    原贴内容:
    btnSearch.Attributes.Add("onclick","document.all('Right').src='xxx.aspx?txbTitle=" + document.all('txbTitle').value + "';return(flase);");我回去了再试试。
      

  12.   

    楼主出现错误,是因为原语句里面的单引号太多,相互之间影响导致的.
    我上述的改法,即基于此点,直接把单引号值去除.其实也可如下:
    btnSearch.Attributes.Add("onclick","var tmp=document.all('txbTitle').value;document.all('Right').src='xxx.aspx?txbTitle=" + tmp + "';return(flase);"); 
      

  13.   

    hchxxzx(NET?摸到一点门槛) :在vs2003中, 为什么两句都说:
    类、结构或接口成员声明中的标记“(”无效
    类、结构或接口成员声明中的标记“+”无效就是这个:
    btnSearch.Attributes.Add(   
    document.all('txbTitle').value +
      

  14.   

    btnSearch.Attributes.Add("onclick","var tmp=document.all('txbTitle').value;document.all('Right').src='xxx.aspx?txbTitle=' + tmp;return(flase);"); 
      

  15.   

    我要问的就是怎么把值传到Iframe中,asp.net中的action是默认本页的,加了
    <form runat="server" onsubmit="this.action='xxx.aspx';">
    在xxx.aspx中Request.Form来获取数据
    这个不能解决xxx.aspx显示在Iframe中用Response.Redirect又没有Target的属性,我还能怎么做?------------------------------------------------------------
    看楼主的意思,似乎是要把数据提交到iframe?那设置<form>的Target参数等于iframe的name就可以了啊。
      

  16.   

    例:
    框架页:
    <body>
    <form id="Form1" method="post" runat="server">
    <iframe align="left" id="Left" scrolling="auto" src="Left.aspx"></iframe>
    <iframe align="right" id="Right" scrolling="auto" src="Right.aspx"></iframe>
    </form>
    </body>
    left.aspx页:
    <body>
    <form id="Form1" method="post" runat="server">
    <FONT face="宋体">
    <P>
    <asp:TextBox id="TextBox1" runat="server"></asp:TextBox></P>
    <P><INPUT type="button" value="Button" onclick="top.Right.document.location='right.aspx?R='+TextBox1.value;"></P>
    </FONT>
    </form>
    </body>
    Right.aspx页:
    在form_load事件中获取参数R的值查询数据并显示查询结果。
      

  17.   

    非常谢谢大家特别是: ffjing(猪头不卖) ,你的方法果然行,又简单又实用!!!