请问如何从一个iframe中的按钮去开另外一个iframe的页面

来源:百度知道 编辑:UC知道 时间:2024/05/10 22:53:05
我的页面中有2个iframe.
其中一个iframe(iframe1)中的一个LinkButton需要到另外一个iframe中开一个网页:
protected void MainListCourseNameLinkButton_Click(object sender, EventArgs e)
{
GridViewRow gvr = (GridViewRow)((LinkButton)sender).Parent.Parent;
Session["CourseID"] = MainListGridView.DataKeys[gvr.RowIndex].Values[0];
//Response.Write("window.getElementById.Introduce.location = \"Introduce.aspx\";");
//Response.Write("javascript:window.iframe的名字.location = \"Introduce.aspx\";");
//Response.Redirect("Introduce.aspx?CourseID=" + MainListGridView.DataKeys[gvr.RowIndex].Values[0] );
//document.frames("Introduce").location.reload();
//Response.Write("Introduce.window.location.reload()");
//Response.Write("javascript:parent.Introduce.location.reload(true);");
}
这是我写的代码,C#,注释掉的都是要不得的

直接用javascript写:
parent.frames('Iframe2').location.href='aaaa.aspx';
后台
Page.RegisterClientScriptBlock("js", "<script>parent.frames('Iframe2').location.href='aaaa.aspx';</script>");
这段代码是我从我的程序里直接摘出来的,我用的是vs.net2005,应该是好使的。不过这种方式在net2.0中是过期的,你可以试试用ClientScript.RegisterClientScriptBlock方法调用。
下面是我刚刚做的一个测试界面:
-----------------------
default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/19