我发现这个非常酷的页面允许您将 facebook 连接到您的站点:See here
<iframe id="MyIframe" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.EXAMPLE.com%2F&layout=button_count&show_faces=true&width=100&action=recommend&colorscheme=light&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&layout=button_count&show_faces=true&width=100&action=recommend&colorscheme=light&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&layout=button_count&show_faces=true&width=100&action=recommend&colorscheme=light&height=21");
关于c# - 从背后的 ASP.NET 代码与 iFrame 对话,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3945176/