Click here to Skip to main content
15,918,516 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted

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.
}
}
 
Share this answer
 
hello,

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

MIDL
Random r = new Random(10000);
        myIframe.Attributes.Add("src", "http://myserver/result.aspx?id=1&r=" + r.Next().ToString());
 
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