Error refreshing a web page

ieerror3

This is browser normal behavior. if the current page is a result of a postback (button clicked rather than a hyperlink), then to do a refresh the browser needs to post the data again (rerunning the page logic);
because so many sites failed to handle this on their purchase page, the browsers had to add this message to prevent double buys.

How to suppress this behavior
Browser displays that message only if page is result of submitting form with method POST. Which is how any buttom works in .NET you can get away with that if any action (i.e. button click) you will end with Response.Redirect somewere. Then it will me method “GET”.

UFrame: UpdatePanel and IFRAME combined

UFrame combines the goodness of UpdatePanel and IFRAME in a cross browser and cross platform solution. It allows a DIV to behave like an IFRAME loading content from any page either static or dynamic. It can load pages having both inline and external Javascript and CSS, just like an IFRAME. But unlike IFRAME, it loads the content within the main document and you can put any number of UFrame on your page without slowing down the browser. It supports ASP.NET postback nicely and you can have DataGrid or any other complex ASP.NET control within a UFrame. UFrame works perfectly with ASP.NET MVC making it an replacement for UpdatePanel. Best of all, UFrame is implemented 100% in Javascript making it a cross platform solution. As a result, you can use UFrame on ASP.NET, PHP, JSP or any other platform.

<div class=”UFrame” id=”UFrame1″ src=”SomePage.aspx?ID=UFrame1″ >
  <p>This should get replaced with content from Somepage.aspx</p>
</div>

Response from SomePage.aspx is rendered directly inside the UFrame. Here you see two UFrame’s are used to load the same SomePage.aspx as if they are loaded inside IFRAME. Another UFrame is used to load AnotherPage.aspx that shows photos from Flickr.

See it in action!
You can test UFrame from:
http://labs.dropthings.com/UFrame2005 – Visual Studio 2005 version, .NET 2.0 implementation showing regular ASP.NET 2.0 controls work as usual
http://labs.dropthings.com/UFrameMvc – Visual Studio 2008 version shows ASP.NET MVC works fine making UFrame an ultimate replacement for UpdatePanel

What is UFrame?
UFrame can load and host a page (ASP.NET, PHP or regular html) inside a DIV. Unlike IFRAME which loads the content inside a browser frame that has no relation with the main document, UFrame loads the content within the same document. Thus all the Javascripts, CSS on the main document flows through the loaded content. It’s just like UpdatePanel with IFRAME’s src attribute.

The features of UFrame are:

  • You can build regular ASP.NET/PHP/JSP/HTML page and make them behave as if they are fully AJAX enabled! Simple regular postback will work as if it’s an UpdatePanel, or simple hyperlinks will behave as if content is being loaded using AJAX.
  • Load any URL inside a DIV. It can be a PHP, ASP.NET, JSP or regular HTML page.
  • Just like IFRAME, you can set src property of DIVs and they are converted to UFrames when UFrame library loads.
  • Unlike IFRAME, it loads the content within the main document. So, main document’s CSS and Javascripts are available to the loaded content.
  • It allows you to build parts of a page as multiple fully independent pages.
  • Each page is built as standalone page. You can build, test and debug each small page independently and put them together on the main page using UFrames.
  • It loads and executes both inline and external scripts from loaded page. You can also render different scripts during UFrame postback.
  • All external scripts are loaded before the body content is set. And all inline scripts are executed when both external scripts and body has been loaded. This way the inline scripts execute when the body content is already available.
  • It loads both inline and external CSS.
  • It handles duplicates nicely. It does not load the same external Javascript or CSS twice.

Download the code

You can download latest version of UFrame along with the VS 2005 and VS 2008 (MVC) example projects from CodePlex: www.codeplex.com/uframe
Please go to the “Source Code” tab for the latest version. You are invited to join the project and improve it or fix bugs.

(Sursa: http://www.codeproject.com/KB/aspnet/uframe.aspx)

Build dynamic IFrames in ASP.NET

Create the HtmlGenericControl object that will eventually render as an iframe and specify whatever attributes this iframe will have:

// Create new iframe control
HtmlGenericControl searchFrame = new HtmlGenericControl(“iframe”);
searchFrame.ID = “searchFrame”;
searchFrame.Attributes.Add(“class”, “searchFrame”);
searchFrame.Attributes.Add(“frameborder”, “0”);

Then, you can add it to the PlaceHolder’s controls collection:

// Add it to the Controls collection of the PlaceHolder control
searchHolder.Controls.Add(searchFrame);

Finally,  add the PlaceHolder control into ascx document where I’d like the iframe to eventually be:

<div class=”searchContainer”>
   <asp: PlaceHolder id=”searchHolder” runat=”server” />
</div>

Now, an iframe will appear in the outputted HTML code where the placeholder once was. But more than that, since was used an ASP.NET control to actually create the iframe, the iframe will be named uniquely. We even know what it’ll be called: this.UniqueID + “_searchFrame”. This is beneficial since you can now reference that iframe by name throughout  JavaScript code and show it or hide it when necessary.

If you are going to use this on a secure page (using https), you’ll have to set the src of the iframe to something on the site, otherwise you get a warning (at least in IE) telling you that the page contains secure and non-secure items. I’ve seen people create a blank HTML page in the site and set the src to that. I set the src = “javascript:;”. That takes care of the warning. If you have inherited your user control from either a User Control or a Web Control, you can implement the marker interface INamingContainer and multiple instances of your controls will have a unique name. I’m not certain if you can do that with a user control, but I can’t think of any logical reason why you couldn’t.

(sursa: http://www.roryhansen.ca/2005/08/22/using-iframes-in-aspnet/)