WhoIsKB - Kevin Blakeley

Public WebLog WhoIsKb() { return "Random experiences with .Net" ; }

<September 2008>
SuMoTuWeThFrSa
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011


Navigation

Tools I Love

Subscriptions

Post Categories



ASP.net Tracing in a popup window

I just saw Dino's post on his wish list for ASP.Net tracing and saw he wanted the tracing window in a popup window.  This is something we wanted for our web apps as well, so here is how I tackled the problem. I know its not perfect and the output is still put out to the main page, but the reason why I had to come up with this scheme was because in our web apps we are using absolute positioning. When we did this our content was placed over the top of the trace div.

Here is the code.....

============== Parent ASPX Page =================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
 <HEAD>
  <TITLE>Parent Page</TITLE>
  <SCRIPT>
  function SetupTraceWindow()
  {
   var div = GetTraceDiv();
   if(div==null) return;
   
   win = window.open("Trace.htm","Trace");
   if(win==null) windown.status="The trace window was blocked.  Please make sure popup blockers are off.";
  }

  // Called by the child window to get the html of the trace output and also hides the trace output on the parent page.
  function GetTraceHTML()
  {
   var div = GetTraceDiv();
   if(div==null) return "";
   var html = div.outerHTML;
   div.style.display="none";
   return html;
  }

  // Returns the div that is created by the ASP.Net trace function
  function GetTraceDiv()
  {
   var div = document.getElementById('__asptrace');
   return div;
  }
  </SCRIPT>
 </HEAD>
 <BODY ms_positioning="GridLayout" onload="SetupTraceWindow();">
  <FORM id="Form1" method="post" runat="server">
  This is the parent page.
  </FORM>
 </BODY>
</HTML>

======================= Trace.htm =======================
<!DOCTYPE html public "-//w3c//dtd html 4.0 transitional//en">
<HTML>
<HEAD>
<TITLE>ASP.Net Trace Output Popup</TITLE>
<SCRIPT language="javascript">
function SetupTrace()
{
 var html = opener.GetTraceHTML();
 document.writeln(html);
 opener.focus();
}
</SCRIPT>
</HEAD>
<BODY onload="SetupTrace()">
<DIV id="myTrace"></DIV>
</BODY>
</HTML>

posted on Tuesday, June 01, 2004 12:14 PM by whoiskb





Powered by Dot Net Junkies, by Telligent Systems