c# - 从背后的 ASP.NET 代码与 iFrame 对话

标签 c# asp.net vb.net facebook iframe

我发现这个非常酷的页面允许您将 facebook 连接到您的站点:See here

<iframe id="MyIframe" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.EXAMPLE.com%2F&amp;layout=button_count&amp;show_faces=true&amp;width=100&amp;action=recommend&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:21px;" allowTransparency="true"></iframe>

我希望能够在我的页面中调用此 iframe(我使用的是 ASP.NET)并且我希望能够根据变量设置可见性,最重要的是我希望能够更改基于由变量构建的字符串的 iframe,以根据页面位置将“www.EXAMPLE.com”更改为另一个 URL。

最佳答案

尝试添加属性 runat="server"。这应该允许您通过代码 Conceal 访问标签,这将允许您根据变量设置其他属性。:

<iframe id="MyIframe" runat="server" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.EXAMPLE.com%2F&amp;layout=button_count&amp;show_faces=true&amp;width=100&amp;action=recommend&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:21px;" allowTransparency="true"></iframe>

这将使您可以在代码 Conceal 中通过名称访问您的 iframe。然后,您将能够通过编写如下语句来操纵事物:

MyIframe.Visible = true;

MyIframe.Attributes.Add("src", "http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.EXAMPLE.com%2F&amp;layout=button_count&amp;show_faces=true&amp;width=100&amp;action=recommend&amp;colorscheme=light&amp;height=21");

关于c# - 从背后的 ASP.NET 代码与 iFrame 对话,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3945176/

相关文章:

vb.net - 使用文本框搜索 datagridview 中的列 (vb.net)

mysql - 在 MySQL 中的列上自定义排序依据

c# - 不能使用 columnwidth excel 属性

c# - 如何将 C++ union 类型转换为 C# 代码?

c# - LINQpad 线程行为

vb.net - 'Uri()'类型的值不能转换为 'List(Of Uri)'

c#:脉冲并等待

asp.net - 如何在 ASP.Net 应用程序中设置默认时区

c# - session 变量在不同浏览器之间共享吗?

c# - TransactionScope 和 DataContext