本文介绍了在的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", "www.google"); URLInvalid.Visible = false; } }我也试过: PayPalFrame.Attributes [SRC] =http://www.google; ,仍然一无所获。
推荐答案我已经测试了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", "www.ironworks"); } } }我要检查你的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不更新
发布评论