Click here to Skip to main content
14,384,229 members
Rate this:
Please Sign up or sign in to vote.
Hi all,

I have a single page with a datagrid (on the left hand side) and an iframe (on the right hand side). The datagrid is filled with all vehicles' data from database, while the iframe is filled with a Google map to plot these vehicles.

The iframe actually loads another page to do the plotting.

Issue: I am refreshing the datagrid on timer tick. But, the iframe is not getting refreshed at the same time. So, the map is not getting plotted again with new data. How do I change the iframe src from code behind page on timer tick event?

I have tried the following code on timer tick (code behind) with no effect:

Protected Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs)
     iframe1.Attributes("src") = "GmapAll.aspx"      ( not working )
     iframe1.Attributes.Add("src", "GmapAll.aspx")   ( not working )
End Sub

FillGrid() method fills the datagrid. createXMLFile() method creates XML file, and it's path is passed to GmapAll.aspx page (which does the plotting).

Pl help me refresh the iframe on timer tick.

Thanks in advance.
Rate this:
Please Sign up or sign in to vote.

Solution 1

Try this:
<iframe height="450px" width="450px" scrolling="auto" runat="server" id="iFrame1" />

protected void Page_Load(object sender, EventArgs e)
    string Url = "TXT/business applications_en.htm";
    //iFrame1.Attributes["src"] = Url;
    System.Web.UI.AttributeCollection aCol = iFrame1.Attributes;
    aCol.Add("src", "Test\test.aspx");


Try this: add a hidden input field (with runat="server" attribute) and change it's value to your IFrame's src in the JavaScript. That way, you'll be able to read the field's value server-side.

debo_india 28-Jul-12 2:09am
hi thanks for the answer..i tried this. its not working.
_Amy 28-Jul-12 2:17am
Try my updated answer.
debo_india 28-Jul-12 2:46am
hi i tried both of the above..none are working..
ErBhati 18-May-13 2:07am
Thanks amit
Rate this:
Please Sign up or sign in to vote.

Solution 2

ifrmMain.Attributes["src"] = "Your page name";

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100