Monday, February 26, 2007

logging application block 2.0 (LoggingSettings, ConfigurationManager, GetSection, TraceListener Information)

working on reading form this loggingconfiguration section was a bit tuff, I would to the properties collections for the tracelisteners, and still get stuck, not getting any info. Pair programming on it with a collegue from octo technologies, it was great that we came up with this solution. I propose the logging application block, work with it, and my collegue brings in his experience with reading configuration files. in this context, i'll talk about this as an gile technique later on, in another post.

the result is below, not much, but a modest, useful piece of code

retreiving the fileName of a flatfile tracelistener from the LoggingConfiguration Section of the configuration file.
This can be done in using the following function:

//recives The name of the trace listener, and property desired of this tracelistener
//example: string fileName = GetTraceListenerInfo("FLTraceListener1", "fileName");
private string GetTraceListenerInfo(string name, string property)

//LoggingSettings is the class representing the collection
LoggingSettings ls = ConfigurationManager.GetSection("loggingConfiguration") as LoggingSettings;

//getting into the trace listeners collection
if (ls.TraceListeners != null)
TraceListenerData tld = ls.TraceListeners.Get(name);
PropertyInformation pi = tld.ElementInformation.Properties[property];

//get the property value
return pi.Value.ToString();
return string.Empty;

Comments Welcome!

Sunday, February 18, 2007

Enter key Navigation and 2.0

there are two ways of getting to navigate with the enter key. one is using the panel control's property "DefaultButton".

another method, is to use the onkeydown event of the body element to detect the enter key "keycode=13".
here's the function that would detect the enter key:
>> body onkeydown='ManageKeyDown'
function ManageKeyDown(e)
var code;
if(window.event) // for IE
code= e.keyCode;
else if(e.which) // for Netscape/Firefox/Opera
code= e.which;
if (code== 13) // if it's the enter key
//here goes the implentation necessary to execute a button

this is another way, which is a bit more flexible, and works with ajax. while the defaultButton property of a panel may not work with the update panel (from my experience with this technique).

comments welcome