动态地从页面后面的代码更改iFrame src [英] change iFrame src from code behind page dynamically

查看:104
本文介绍了动态地从页面后面的代码更改iFrame src的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我有一个带有数据网格的页面(在左侧)和一个iframe(在右侧)。数据网格填充了来自数据库的所有车辆数据,而iframe填充了Google地图以绘制这些车辆。



iframe实际上会加载另一个页面来进行绘图。



问题:我正在刷新数据网格在计时器上打勾。但是,iframe没有同时刷新。因此,地图不会再次使用新数据绘制。如何在计时器刻度事件中从代码页面后面更改iframe src?



我在计时器刻度(后面的代码)上尝试了以下代码,但没有效果:



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()方法填充数据网格。 createXMLFile()方法创建XML文件,并将其路径传递给GmapAll.aspx页面(进行绘图)。



Pl帮我刷新计时器上的iframe。



提前谢谢。



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.

推荐答案



试试这个:

Hi,
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");
}









试试这个:添加一个隐藏的输入字段(使用runat =server属性)并将其值更改为JavaScript中的IFrame的src。这样,您就可以阅读该字段的值服务器端。



--Amit



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


ifrmMain.Attributes [src] =您的页面名称;
ifrmMain.Attributes["src"] = "Your page name";


这篇关于动态地从页面后面的代码更改iFrame src的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆