【发布时间】:2012-09-11 16:51:11
【问题描述】:
当单击页面上的按钮时,我正在尝试更新 iFrame 的源。然而,似乎什么都没有发生……
.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>
代码隐藏:
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"] = "http://www.google.com"; 还是什么都没有。
【问题讨论】:
-
如果在
SubmitSponsor内设置断点,它会被命中吗? -
我已经有一段时间没有使用更新面板了,但您不必指出哪些按钮会触发面板更新和重新渲染吗?
-
@DaveZych 是的,它通过 SubmitSponsor 中的每个命令就好了。
-
@AnnL。不,除了更新 src 属性之外,它适用于我尝试过的任何其他方法。