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();
}
else
{
return string.Empty;
}
}


Comments Welcome!

Sunday, February 18, 2007

Enter key Navigation and asp.net 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
{
alert(code);
//here goes the implentation necessary to execute a button
document.getElementById("button1").click();
}
}


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





Wednesday, December 27, 2006

using a dataset versus using a datareader

DataSet:
1. used to retreive data in a disconnected manner.
2. can be serialized and transported to another system (using xml)
3. extremely flexible for manipulating data.

DataReader:
1. used to retreive data in a connected manner, until closed.
2. cannot be serilized, and is used only for read scenarios.

Internal functionning of the dataset:
1. it uses a DataReader to retreive its data, and then disconnect.
2. its structure is persisted in memory or using xml.

in this case, it is useless to use the dataset, in order to fill another structure such as a generic list System.Collections.generic.List, System.Collections.generic.List(Of T).

It is better to use a datareader to fill a generic list.

for more information on this:
perfomance check list for ado.net
http://msdn2.microsoft.com/en-us/library/ms998589.aspx
Imporving ADO.NET performance
http://msdn2.microsoft.com/en-us/library/ms998569.aspx



very useful information.
comments welcome,
happy programming!

Thursday, September 07, 2006

QueryString and sitemap providers

a great solution can be found at C# Shiznit blog
http://www.csharper.net/blog/custom_sitemapprovider_incorporates_querystring_reliance.aspx

the solution works great, i have tested it, and used it in on my project. I lost a sample app. with this example, i'll try and make another sample for download.

Wednesday, August 16, 2006


MCAD.net Posted by Picasa