.net在iframe里面怎么实现不刷新,点击left.aspx页面到right.aspx页面实现不刷新呢,我用了 <asp:UpdatePanel ID="UpdatePanel2" runat="server"  UpdateMode="Conditional"> 
        <ContentTemplate> 
.net的ajax功能,不起作用,,在一个页面的可以实现局部刷新,当时在框架的三个页面,就不起作用了我怎样才可以实现这种效果呢,

解决方案 »

  1.   

    在right.aspx中放一个隐藏的按钮
    在left.aspx页面中的某个控件事件中调用这端js,
    用这段js激发right.aspx页面中的隐藏按钮的click事件
    这样right。aspx页面的updatepanel就能起作用了
      

  2.   

    可以有个例子吗??我不太清楚
      public void createChild(Tree tree, string chap_id)
        {
            ChapBLL bll = new ChapBLL();
            Sqlhelpers ss = new Sqlhelpers("line");
            DataSet ds = bll.checkChildById(chap_id);
            string imgsrc = "tree2/icons/search_globe.gif";
            DataTable table = ds.Tables["chap"];
            if (ds.Tables[0].Rows.Count > 0)
            {            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    string id = ds.Tables[0].Rows[i]["chap_id"].ToString();                string chap = ds.Tables[0].Rows[i]["chap"].ToString();
                    tree.Add(chap_id, id, chap, false, null, null);
                    DataSet obj2 = new DataSet();
                    obj2 = bll.checkChildById(id);
                    if (obj2.Tables[0].Rows.Count > 0)
                    {
                        createChild(tree, id);
                    }
                    else
                    {
                        string linkHtml1 = "<a href ='right.aspx?chap_id=" + id + "&tixing=1'target='main' style='color:black; font-size:15px;text-decoration:none;'>选择题</a>";
                        string linkHtml2 = "<a href ='right.aspx?chap_id=" + id + "&tixing=2'target='main' style='color:black; font-size:15px;text-decoration:none;'>判断题</a>";
                        tree.Add(id, 0, linkHtml1, false, null, null);
                        tree.Add(id, 0, linkHtml2, false, null, null);
                        createChild(tree, id);
                    }
                  
                }
             
              
            }
    这是我Left.aspx的代码,是树结构string linkHtml1 = "<a href ='right.aspx?chap_id=" + id + "&tixing=1'target='main' style='color:black; font-size:15px;text-decoration:none;'>选择题</a>";
    这段代码,"<a href ='right.aspx?到right.aspx进行数据的显示
      

  3.   

    你改变url,当然会刷新了在name=rightframe的页面也就right.aspx
    1)在UpdatePanel 里加个隐藏的button
    <asp:Button runat="server" style="display:none" ID="button1" Onclick="button1_click">
    2)在form里加个HiddenField 
    <asp:HiddenField ID="HiddenField1" runat="server" />
    3)button1_click事件里
    chap_id = HiddenField1.Value;
    4)加js给HiddenField赋值function,用来给left.aspx里调用
    function setValue(val)
    {
       document.getElementById("HiddenField1").value=val;
       document.getElementById("button1").click();
    }
    在左边的框架页面也就Left.aspx
    1)加js function 
    function rightNavi(id)
    {
       window.parent.rightframe.setValue(id);
    }
    2)后台链接改成调用上面function
      string linkHtml1 = " <a href =\"javascript:rightNavi('"+id +"')\">选择题 </a>"; 
      

  4.   

    button1_click用来根据HiddenField1.Value刷新右框架里的数据
      

  5.   

    呵呵,不用在right.aspx放按钮吧,有js函数不就行了?
    点击left里的按钮
    调用iframe的js函数来更新right的页面数据不就行了?问题是既然你用ajax,干嘛还要个iframe干嘛?难道iframe里的页面是另外的什么网站页面,你想控制它?如果是这样,可能会有权限的问题,那非得只能刷新页面才能更新了。
      

  6.   

    呵呵,当然可以,js调用function,注册一个Ajax Mehtod就可以了
      

  7.   

    要更新数据的地方,外面也套用一个UpdatePannel
      

  8.   

      <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
             <asp:HiddenField ID="HiddenField1" runat="server" /> 
            <asp:Button runat="server" style="display:none" ID="button1" Onclick="button1_click"/> 
             >
              
            </ContentTemplate>
            </asp:UpdatePanel>这是我的代码
      

  9.   

    你是说两个  <asp:UpdatePanel 吗??
      

  10.   

      <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
             <asp:Button id="Button2" runat="server" Text="Button" OnClick="Button2_Click1"></asp:Button>
                <asp:Label ID="Label1" runat="server" Text="Label" Width="88px"></asp:Label>
             <asp:HiddenField ID="HiddenField1" runat="server" /> 
            <asp:Button runat="server" style="display:none" ID="button1" Onclick="button1_click"/>&nbsp;&nbsp;
            </ContentTemplate>
            </asp:UpdatePanel>
            
            
            
            <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
                <ContentTemplate>
                <asp:GridView ID="GridView1" runat="server">
                </asp:GridView>
                </ContentTemplate>
            </asp:UpdatePanel>我用了两个 UpdatePanel,,,GridView是更新的部分,是这样么
      

  11.   

      
            <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional"> 
                <ContentTemplate> 
    <asp:Button id="Button2" runat="server" Text="Button" OnClick="Button2_Click1"> </asp:Button> 
                <asp:Label ID="Label1" runat="server" Text="Label" Width="88px"> </asp:Label> 
            <asp:HiddenField ID="HiddenField1" runat="server" /> 
            <asp:Button runat="server" style="display:none" ID="button1" Onclick="button1_click"/>&nbsp;&nbsp;
                <asp:GridView ID="GridView1" runat="server"> 
                </asp:GridView> 
                </ContentTemplate> 
            </asp:UpdatePanel>