Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
4.00/5 (1 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)
     FillGrid()
     createXMLFile()
     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.
Posted

Hi,
Try this:
ASP.NET
<iframe height="450px" width="450px" scrolling="auto" runat="server" id="iFrame1" />

C#
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");
}


OR

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.

--Amit
 
Share this answer
 
v3
Comments
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
ifrmMain.Attributes["src"] = "Your page name";
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900