Talking to iFrame from ASP.NET code behind

I found this really cool page that allows you to hook up facebook into your site: 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>

I want to be able to call this iframe in my page (I am using ASP.NET) and I want to be able to set the visibilty based on a variable and most important I want to be able to change the src of the iframe based on a string that is build up by variables to change the "www.EXAMPLE.com" to another URL based on the location of the page.

Answers


Try adding the attribute runat="server". This should give you access to the tag via your codebehind, which will let you set other attributes according to your variable.:

<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>

This will give you access to your iframe by name in code behind. You'll then be able to manipulate things by writing statements like:

MyIframe.Visible = true;

and

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");

Need Your Help

grep a large list against a large file

linux shell unix awk grep

I am currently trying to grep a large list of ids (~5000) against an even larger csv file (3.000.000 lines).

iCalendar "Field" list (for database schema based on iCalendar standard)

sql icalendar

my application has to deal with calendar information (incl. single occurrence, recurrence, etc.). In order to easily interface with other applications I thought that it would be a good idea to crea...