iframe 中是另外一个页面,子页面b,子页面的按钮最后想调用父页面a的方法,如何做
b页面:
b页面最后调用a页面的BindRepeater()方法。

protected void btnOk_Click(object sender, EventArgs e)
{
string sum = "";
for (int i = 0; i < Repeater1.Items.Count; i++)
{
CheckBox cb = (CheckBox)Repeater1.Items[i].FindControl("CheckBox1");
if (cb.Checked)
{
sum += cb.ToolTip + "_" + cb.Text + "ttttt";
}
}
if (sum.Length > 2)
{
sum = sum.Substring(0, sum.Length - 6);
}
Session["Sight"] = sum;
Page.ClientScript.RegisterStartupScript(this.GetType(), "Begin", " <script>ymPrompt.close();top.document.all.btnOk.btnOk_Click (); </script>");
}b页面最后调用a页面的BindRepeater()方法。
private void BindRepeater()
{
try
{
//if (Session["Sight"]==null )
//{
// return;
//}
string sum = Session["Sight"].ToString();
if (sum.Length < 2)
{
return;
}
DataTable dt = new DataTable();
dt.Columns.Add("SightName", typeof(string));
dt.Columns.Add("SightId", typeof(int));
Regex r = new Regex("ttttt");
foreach (string item in r.Split(sum))
{
DataRow dr = dt.NewRow();
dr["SightId"] =Convert.ToInt32( item.Substring(0, item.IndexOf('_') ));
dr["SightName"] = item.Substring(item.IndexOf('_')+1);
dt.Rows.Add(dr);
}
Repeater2.DataSource = dt;
Repeater2.DataBind();
}
catch (Exception err)
{
}
}
...全文
相关推荐
iframe父页面与子页面通信及相互调用方法
本Demo汇总是iframe父页面与iframe子页面如何相互调用方法、元素及值的几种常见方法(含JS、JQuery方法)
在iframe中调用js父页面和子页面方法
NULL 博文链接:https://747017186.iteye.com/blog/1985110
子页面访问父页面 和 跨iframe访问
NULL 博文链接:https://pireswang.iteye.com/blog/325571
iframe与父页面传值(方法互调)
NULL 博文链接:https://skying007.iteye.com/blog/1044069
js中iframe调用父页面的方法
本文实例讲述了js中iframe调用父页面的方法。分享给大家供大家参考。具体实现方法如下: 子页面调用父页面的方法在js中很容易实现。我们只需要在主页面加个函数,然后在子页面通过window.parent.方法()即可实现了 比如调用a()函数,就写成: 代码如下:window.parent.a(); 但是我在chrome浏览器下却发现此方法无效了 代码如下://在父页面中调用该函数 [removed] function dey() { var cards_frame=document.frames(“card-iframe”); //card-iframe为iframe的名字


