iframe无法为相同的网址加载 [英] Iframe not loading for same url

查看:141
本文介绍了iframe无法为相同的网址加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在按钮上单击页面,将src属性赋予IFRAME,页面加载正常.

例如http://myserver/result.aspx?id = 1

对于第二个单击按钮,当传递了不同的URL时,页面加载正常
例如http://myserver/result.aspx?id = 2


对于第二个按钮,当传递相同的URL时,请单击,以防第2页未在iframe中加载.
例如http://myserver/result.aspx?id = 2

如何防止这种行为.即使src网址相同,我也想加载iframe.

谢谢

Vijay

Hi,

On a button click on a page, I give src attribute to the IFRAME and page loads fine.

e.g. http://myserver/result.aspx?id=1

For a second button click when different url is passed page loads fine
e.g. http://myserver/result.aspx?id=2


For a second button click when same url is passed as in case 2 page doesnt load in iframe.
e.g. http://myserver/result.aspx?id=2

How to prevent this behaviour. I want to load iframe even if the src url is same.

Thanks

Vijay

推荐答案

我认为您在!IsPostBack中遇到问题.
当您单击第二个按钮时,将再次调用Page_Load方法.
因此,请执行以下操作->

受保护的void Page_Load(对象发送者,EventArgs e)
{
如果(!IsPostBack)
{
//您的默认网址集.
}
}
I think you have a problem in !IsPostBack.
When you click the 2nd button then Page_Load method is again called.
so, do something like this ->

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
// your default url set.
}
}


你好,

如何在网址后附加一个随机数?在这种情况下,URL将始终是不同的.

hello,

How about appending a random number to the url? In that case the URL will always be different.

Random r = new Random(10000);
        myIframe.Attributes.Add("src", "http://myserver/result.aspx?id=1&r=" + r.Next().ToString());


这篇关于iframe无法为相同的网址加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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