in

ASP.NET Weblogs

Andrew Frederick

View Source Trick for Pages with Partial Rendering

Many people when developing want to look at the browser’s View Source to make sure that things are being outputted correctly or to see where in the DOM certain things are showing up. However, if you are using the Ajax concept of partial rendering (usually via UpdatePanels), what you get is the initial state of the page when it was first loaded before any partial page updates, not the state of the page as it is currently.

To see the “current” source for the page, simply paste the following code into your browser’s location bar. It’s a little long, but it covers most browsers.

javascript:if (typeof(window.document.body.outerHTML) != 'undefined'){'<xmp>'+window.document.body.outerHTML+'</xmp>'} else if (typeof(document.getElementsByTagName('html')[0].innerHTML) != 'undefined'){ '<xmp>'+document.getElementsByTagName('html')[0].innerHTML+'</xmp>'} else if (typeof(window.document.documentElement.outerHTML) != 'undefined'){ '<xmp>'+window.document.documentElement.outerHTML+'</xmp>'} else { alert('Your browser does not support this.') }

Comments

 

rajbk said:

..or you could use a firefox addin

www.chapter31.com/.../viewing-ajax-generated-source-code

Raj

February 20, 2008 3:05 PM
 

Joe Chung said:

Firebug does a live presentation of the DOM as it gets updated with script, too.

February 20, 2008 9:25 PM
 

rascunho » Blog Archive » links for 2008-02-21 said:

Pingback from  rascunho  &raquo; Blog Archive   &raquo; links for 2008-02-21

February 21, 2008 3:27 PM
 

travistx said:

Nice.  I also found that you can add this javascript to your favorites.  It can then be used to view the source on any page with a couple of clicks.

February 25, 2008 5:13 PM

Leave a Comment

(required)  
(optional)
(required)  
Add