<%@ Control Language="C#" AutoEventWireup="false" %> <% // OpenAjaxEventLog.ascx // Implementation of the OpenAjaxEventLog Control. // Copyright (c) by Matthias Hertel, http://www.mathertel.de // This work is licensed under a BSD style license. See http://www.mathertel.de/License.aspx // ----- // This control is used to display all OpenAjax hub events in a div area for debugging purpose. // ----- // 10.08.2007 created by Matthias Hertel // 25.08.2007 better output formatting for complex objects %> <div id="<%=this.ClientID %>" style="border: solid 1px blue; height: 8em; padding:2px;overflow: hidden"> <h3 style="margin: 0px">OpenAjax hub event log:</h3> </div> <script type="text/javascript"> obj = document.getElementById("<%=this.ClientID %>"); obj.dumpevent = function (eventName, eventData) { this.Dump(eventName + ":" + this._objToText(eventData)); } // dumpevent obj.Dump = function (txt) { var p = window.document.createElement("div"); this.appendChild(p); p.innerText = txt; if (this.childNodes.length > 14) this.removeChild(this.childNodes[1]); } // GetValue // get some pretty printable object notation in one line obj._objToText = function(obj) { var s = ""; if (obj == null) { s = "(null)"; } else if (obj.constructor == String) { s = "\"" + obj + "\""; } else if (typeof(obj) == "function") { s += " [function]" + obj; } else if (obj.constructor == Array) { s += "["; for (n = 0; n < obj[p].length; n++) { if (n > 0) s += ", "; s += obj[n]; } s += "]"; } else if (obj.constructor == Object) { s += "{"; for (n in obj) { s += n + ": " + obj[n] + ", "; } s += "}"; } else { s = obj.toString(); } return(s); } // _objToText OpenAjax.hub.subscribe("**", "dumpevent", obj); OpenAjax.hub.registerLibrary("OpenAjaxEventLog", "http://www.mathertel.de/OpenAjax/OpenAjaxEventLog"); </script>
This page is part of the http://www.mathertel.de/ web site.
For updates and discussions see http://ajaxaspects.blogspot.com/.