从代码隐藏更改IFrames InnerHtml [英] Changing an IFrames InnerHtml from codebehind

查看:92
本文介绍了从代码隐藏更改IFrames InnerHtml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在运行时从后面的代码中设置iframe的HTML.

I'm trying to set the HTML of an Iframe at runtime, from code behind.

在我的aspx页面中,我有:

In my aspx page i have:

<asp:Button ID="btnChange" runat="server" Text="Change iframe content" 
onclick="btnChange_Click" />

<br />

<iframe id="myIframe" runat="server" />

在后面的代码中:

protected void btnChange_Click(object sender, EventArgs e)
{
    myIframe.InnerHtml = "<h1>Contents Changed</h1>";
}

当我运行此...时,它回发,但完全不更改myIframe的内容... 我在做什么错??

When i run this.... it posts back, but doesn't change the myIframe contents at all... What am i doing wrong??

我需要执行此操作,因为我在结帐流程中实施了3D安全性. 基本上:

I need to do this because im implementing 3D secure into my checkout process.. basically:

1)客户输入信用卡详细信息 2)表格已提交,请与支付网关核对是否需要3d安全.如果是这样,则为银行安全位置生成url以输入信息 3)我对此URL创建一个POST请求,其中包含一个长安全令牌以及其他一些信息.我掌握了此POST请求返回的HTML,需要将其显示在iFrame中.

1) customer enters credit card details 2) form is submitted, checks with payment gateway if 3d secure is required. if so, url is generated for the banks secure location to enter information 3) i create a POST request to this url, that contains a long security token, and a few other bits of information. i get hold of the HTML returned from this POST request, and need to display it in an iFrame.

这里是文档中规定的内容:

Heres what the documentation says to do:

<html>
<head>
<title>Please Authenticate</title>
</head>
<body onload="OnLoadEvent();">
<form name="downloadForm" action="https://mybank.com/vbyv/verify" method="POST">
<input type="hidden" name="PaReq" value="AAABBBBCCCCHHHHHH=">
<input type="hidden" name="TermUrl" value="https:// www. MyWidgits.Com/next.cgi">
<input type="hidden" name="MD" value="200304012012a">
</form>

<script language="Javascript"> <!-- function OnLoadEvent(){ document.downloadForm.target = "ACSframe"; document.downloadForm.submit(); } //--> </script>

<!-- MERCHANT TO FILL IN THEIR OWN BRANDING HERE -->
<iframe src="blank.htm" name="ACSframe" width="390" height="450" frameborder="0">
</iframe>
<!-- MERCHANT TO FILL IN THEIR OWN BRANDING HERE -->
</body>
</html>

推荐答案

您可以尝试以下操作:

protected void btnChange_Click(object sender, EventArgs e)
{
   myIframe.Attributes["src"] = "pathtofilewith.html"
}

或者也许也可以:

protected void btnChange_Click(object sender, EventArgs e)
{
   myIframe.Attributes["innerHTML"] = "htmlgoeshere"
}

这篇关于从代码隐藏更改IFrames InnerHtml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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