.net在iframe里面怎么实现不刷新,点击left.aspx页面到right.aspx页面实现不刷新呢,我用了 <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
<ContentTemplate>
.net的ajax功能,不起作用,,在一个页面的可以实现局部刷新,当时在框架的三个页面,就不起作用了我怎样才可以实现这种效果呢,
<ContentTemplate>
.net的ajax功能,不起作用,,在一个页面的可以实现局部刷新,当时在框架的三个页面,就不起作用了我怎样才可以实现这种效果呢,
在left.aspx页面中的某个控件事件中调用这端js,
用这段js激发right.aspx页面中的隐藏按钮的click事件
这样right。aspx页面的updatepanel就能起作用了
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进行数据的显示
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>";
点击left里的按钮
调用iframe的js函数来更新right的页面数据不就行了?问题是既然你用ajax,干嘛还要个iframe干嘛?难道iframe里的页面是另外的什么网站页面,你想控制它?如果是这样,可能会有权限的问题,那非得只能刷新页面才能更新了。
<ContentTemplate>
<asp:HiddenField ID="HiddenField1" runat="server" />
<asp:Button runat="server" style="display:none" ID="button1" Onclick="button1_click"/>
>
</ContentTemplate>
</asp:UpdatePanel>这是我的代码
<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"/>
</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是更新的部分,是这样么
<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"/>
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>