在的iFrame的UpdatePanel不更新 [英] iFrame in UpdatePanel not updating

查看:196
本文介绍了在的iFrame的UpdatePanel不更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想,当点击页面上的按钮来更新一个iFrame的来源。然而,似乎没有任何要发生的事情...

I'm trying to update the source of an iFrame when a button is clicked on the page. However, nothing seems to be happening...

.ASPX:

    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Always">
        <ContentTemplate>
                <div class="accountInfo">
                    <p class="submitButton">
                        <asp:Button ID="ValidateButton" runat="server" Text="Validate" OnClick="SubmitSponsor" />
                    </p>
                </div>
                <iframe runat="server" id="PayPalFrame" height="150px" width="100%" frameborder="0"></iframe>
        </ContentTemplate>
    </asp:UpdatePanel>

code背后:

    protected void SubmitSponsor(object sender, EventArgs e)
    {
        var driver = new Driver();
        var isvalid = driver.IsAppValid(URL.Text, APILINK, Connstring);

        if (isvalid)
        {
            PayPalFrame.Attributes.Add("src", "http://www.google.com");
            URLInvalid.Visible = false;
        }
    }

我也试过:
PayPalFrame.Attributes [SRC] =htt​​p://www.google.com; ,仍然一无所获。

推荐答案

我已经测试了code,它在一个样本项目如下:

I have tested your code, and it works in a sample project:

ASPX:

<form id="form1" runat="server">
<div>
    <asp:ScriptManager runat="server" />
    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Always">
        <ContentTemplate>
            <div class="accountInfo">
                <p class="submitButton">
                    <asp:Button ID="ValidateButton" runat="server" Text="Validate" OnClick="SubmitSponsor" />
                </p>
            </div>
            <iframe runat="server" id="PayPalFrame" height="150px" width="100%" frameborder="0">
            </iframe>
        </ContentTemplate>
    </asp:UpdatePanel>
</div>
</form>

codebehind:

Codebehind:

public partial class UpdatePanelIFrameTester : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void SubmitSponsor(object sender, EventArgs e)
    {
        bool isvalid = true;
        if (isvalid)
        {
            PayPalFrame.Attributes.Add("src", "http://www.ironworks.com");
        }
    }
}

我要检查你的code和确保没有导致网页刷新/执行完全回发(我改变谷歌将不会让你在标准条件下的iframe中查看它的URL)。

I would inspect your code and ensure nothing is causing your page to refresh/perform a full postback (I changed the URL as google will not allow you to view it in an iframe under standard conditions).

这篇关于在的iFrame的UpdatePanel不更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆