简体   繁体   English

从C#代码在ASP.NET网站中重新加载iframe

[英]Reloading iframe in ASP.NET site from C# code

Trying to reload an iframe after C# has modified its attributes. C#修改其属性后,尝试重新加载iframe。 Here's the page: 这是页面:

<script type="text/javascript">
    function reloadFrame(Map) {
        document.getElementById(Map).contentDocument.location.reload(true);
    }
</script>

<asp:TextBox ID="TextBox1" placeholder="Zip code" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Find locations" onclick="Button1_Click" />
<iframe id="Map" runat="server"></iframe>

And when the button is clicked it runs this: 当单击按钮时,它将运行以下命令:

var zipCode = TextBox1.Text;
Map.Attributes.Add("src", "https://www.google.com/maps/preview#!q=gnc+near%3A+" + zipCode);        
browser.Document.InvokeScript("reloadFrame", new[] { "Map" });

However the line to reload the iframe doesn't work. 但是,重新加载iframe的行不起作用。 Any ideas? 有任何想法吗?

如何通过内联代码为iFrame设置src?

<iframe id="Map" runat="server" src='<%= (TextBox1.Text == "" ? "" : "https://www.google.com/maps/preview#!q=gnc+near%3A+" + zipCode) %>'></iframe>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM