Jul 9 2006

By the Community, For the Community

Category:Bil@l @ 20:59

The By The Community, For the Community samples series will create ASP.NET samples that are in high demand. These samples will not be created by Microsoft but instead by a select group of ASP.NET community member MVPs. You can see their bios below.

On a regular basis, starting Friday July 7th, we will publish a list of potential samples and allow the community to vote on which sample they are most interested in seeing developed. After the voting ends, the select MVPs will then create the sample using best practices. The samples will be published and then linked to from this page on www.asp.net.

For more information, visit this link: By the Community, For the Community

Regards


Tags:

Jul 9 2006

By the Community, For the Community

Category:Bil@l @ 20:59

The By The Community, For the Community samples series will create ASP.NET samples that are in high demand. These samples will not be created by Microsoft but instead by a select group of ASP.NET community member MVPs. You can see their bios below.

On a regular basis, starting Friday July 7th, we will publish a list of potential samples and allow the community to vote on which sample they are most interested in seeing developed. After the voting ends, the select MVPs will then create the sample using best practices. The samples will be published and then linked to from this page on www.asp.net.

For more information, visit this link: By the Community, For the Community

Regards


Tags:

Jul 9 2006

SQL Server Provider Statistics

Category: ASP.NET 2.0 - GeneralBil@l @ 12:14

SQL Server Provider in .NET Framework 2.0 provides a way to generate per-connection reports for measuring performance through a property in the SqlConnection object called StatisticsEnabled.

This is a sample code of how to do so:

SqlConnection conn = new SqlConnection(connectionString);
conn.Open();
conn.StatisticsEnabled = true;

// Perform data access operations

IDictionary stats = conn.RetrieveStatistics();

foreach (DictionaryEntry e in stats)
{
        Response.Write("Key : " + e.Key + " Value : " + e.Value);       
}

conn.ResetStatistics();



Hope this helps!

Regards

Tags:

Jul 7 2006

Microsoft Private Folder 1.0

Category: General | GeneralBil@l @ 11:29

   Microsoft released a new utility to password-protect your folder. This is the description from the Microsoft site:

Microsoft Private Folder 1.0 is a useful tool for you to protect your private data when your friends, colleagues, kids or other people share your PC or account. With this tool, you will get one password protected folder called 'My Private Folder' in your account to save your personal files. Download and have your private folder today!

The following hardware and software are required to run Microsoft Private Folder 1.0:

  • Microsoft Windows XP Home Edition, Professional Edition and Media Center Edition with SP2
  • Super VGA (800 x 600) or higher-resolution video adapter and monitor

Please note: Microsoft Private Folder 1.0 is provided specifically for genuine Windows customers, and requires genuine Windows validation in order to download. The software is free, and does not come with product support.

You can download the utility from: Microsoft Private Folder 1.0

Regards

Tags: ,

Jul 7 2006

Provider ToolKit Configuration Utility - Part 2

Category: ASP.NET 2.0 - GeneralBil@l @ 09:47

In a previous post, Provider ToolKit Configuration Utility, I published a small utility that helps you create all the needed files when you are building a new Service Provider Model.

In this post, I have upgraded that utility to allow you to create Providers not only related to Data Sources but rather to other APIs. Sometimes, we might need to create a provider that talks to a third-party API, which is in this case neither an Oracle, SQL Server, Microsoft Access, etc ...

In addition, the Namespace TextBox has been increaded in width to allow you to use long namespaces and at the same time be able to see it.

You can download the new version from the Files section above.

Hope this helps,

Regards

Tags:

Jul 6 2006

Parameter Types in C#

Category: General | GeneralBil@l @ 08:35

I read a nice article this morning, wanted to share with you, it is an old and every day article I guess. The article is titled: Parameter passing in C#. It explains in details the different parameter types we have in C#. So I will be just summarizing the ideas mentioned there!

In .NET we have mainly two types: reference types and value types. Reference types mainly hold a reference to an object, while a value type holds the data itself.

For example,

public void myMethod (StringBuilder mySB)
{
        mySB = null;
}

StringBuidler sb = new StringBuilder();
sb.Append("Hello World");
myMethod(sb);
Console.WriteLine(sb);


In this example, we created a reference called sb to a StringBuilder and appended some data, then called the myMethod and passing to it the value of sb and not sb itself and the value of sb in this case is a reference to the StringBuilder object. myMethod would now create a new instance of StringBuilder (as a new storage location) whose value is the value of the passed parameter and hence mySB points to the same StringBuilder object. myMethod then sets the mySB to null which means that the value of the instance created within the method is set to null, and hence when we print out the value of sb, it will be Hello World. I hope you were able to see the idea here which is that, we passed a reference to an object and not the object itself.

However, we can still see the value type in .NET in this example with a small varaiation.

public void myMethod (StringBuilder mySB)
{
        mySB.Append("World");
}

StringBuidler sb = new StringBuilder();
sb.Append("Hello ");
myMethod(sb);
Console.WriteLine(sb);
The same example as above, but within the body of the method, we have appended data to the same reference object. When we print out the value of sb it will be "Hello World". Remember, both instance created refere to the same StringBuilder object and hence when you update the value or data inside the object through one reference, the update will be seen by all objects refering to that StringBuilder object. 

We have 4 different types of parameters in C#:

  1. Value Parameters
    Value parameters hold the data itself. When passed to a method, a new storage location is being created in memory. An example illustrates this type:

    public void myMethod (int myInt)
    {
            myInt = 10;
    }
    
    int newInt = 50;
    myMethod(newInt);
    Console.WriteLine(newInt);
    Since the simple data types such as int, double, character are passed by value, the method myMethod will update the current value of newInt and return it back tobe 10.
  2. Reference Parameters
    By default, classes, delegates, interfaces, arrays, etc .. are passed as a reference. However, sometimes you need to pass not only the reference to an object, but rather the whole object. Check this example:
    public void myMethod (ref StringBuilder mySB)
    {
            mySB = null;
    }
    
    StringBuidler sb = new StringBuilder();
    sb.Append("Hello ");
    myMethod(ref sb);
    Console.WriteLine(sb);
    In this example, we have used the ref keyword which is required when we want to pass a variable by ref. Notice that when we pass a parameter to a method preceeded by ref keyword, we are not passing the value of sb (which is a reference to StringBuilder object) but rather the object itself "sb". myMethod won't create a new storage location but rather use the same storage location of sb, so when it set mySB to be null, means that it is setting the reference itself of sb to null, which means that sb now is null and doesn't refer to any StringBuilder object.
  3. Output Parameters
    Output parameters work much like the ref keyword. You pass a parameter with the out keyword, the calling method would fill out some data inside its body, and the updated data will be reflected outside the method. An example clarifies it more:
    public void myMethod (out int myInt)
    {
            myInt = 10;
    }
    
    int newInt;
    myMethod(out newInt);
    Console.WriteLine(sb);
    

  4. Array Parameters
    Array parameters allows you to pass a variable number of parameters to a method.
    public void myMethod (params int[] myInts)
    {
            foreach(int x in myInts)
            {
                    Console.WriteLine(x + " ");
            }
    }
    
    // Either you pass an array
    int[] newInts = {1,2,3};
    myMethod(newInts);
    
    // Or you send seperate parameters
    myMethod(3,5,7,8);
    

Hope you found my post helpful.

Regards

Tags: ,

Jun 27 2006

Store View State in a Persistent Medium, the Proper Way

Category: ASP.NET 2.0 - GeneralBil@l @ 01:13

I kindly invite you to check out my latest article on the ASPAlliance.com with the title:

Store View State in a Persistent Medium, the Proper Way

Hope you will enjoy it!

Regards

Tags:

Jun 26 2006

My visit to Athens-Greece

Category: General | GeneralBil@l @ 07:12

I have been in Athens-Greece for around 2 days in a business trip for  my company CCC. Things are going fine here, enjoying the beautiful Greece!!!

I will be soon back in Beirut!!

Regards

Tags: ,

Jun 18 2006

ToLowerCase or ToUpperCase in XSLT

Category: XSLT, XPath, XMLBil@l @ 20:35

This is a simple sample to show you how to transform the content of an element in an XML file from lower/upper case to upper/lower case

First of all define a variable of the element as:

    <xsl:variable name="Title">
      <xsl:call-template name="ToLowerCase">
        <xsl:with-param name="Field" select="Title"/>
      </xsl:call-template>
    </xsl:variable>

Then define the Template that will do the transformation:

  <xsl:template name="ToLowerCase">
    <xsl:param name="Field" select="''"/>
    <xsl:value-of select='translate($Field,"ABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwxyz")'/>
  </xsl:template>

As you can see we are transforming all letters to lower case, the same can be done with a similar template to translate letters to upper case.

Hope this helps,

Regards

Tags:

Jun 12 2006

First day as a Trainer

Category:Bil@l @ 21:21

Today was my first day as a trainer at Formatech!

I am giving the Programming in XML with the .NET Framework.

I have 6 students in my class, and things went fine I guess for the first day!!!

This course will finish in two weeks, I enjoyed my first session, a new experience, new people to meet, ...

 

Regards

Tags: