C#从内部重新加载iframe内容

时间:2013-09-20 16:03:16

标签: c#

我的网站站长页面中有一个按钮和一个iframe(src是homepageaspx)。

当我点击该按钮时,iframe正确加载了另一个页面(registeruseraspx)。

现在在这个新页面(registeruseraspx)我有一个按钮;当我点击这个按钮时,我希望iframe加载一个新的aspx页面。

我试图从registeruseraspx改变iframe的src属性,但没有任何反应。

请帮帮我

1 个答案:

答案 0 :(得分:0)

要替换iframe中的iframe页面(使用javascript):

self.location.replace('your_new_page.aspx');

//add above javascript line to the onclick event of the button
//on registeruser.aspx page
<input id="myButton"
       type="button" 
       value="Iframe Button" 
       onclick="self.location.replace('your_new_page.aspx');" />

使用registeruser.aspx页面后面的代码:

protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
       myButton.Attributes.Add("onclick", "self.location.replace('your_new_page.aspx')");
    }
}
相关问题