C#: Get Parent Control with Generics

by Pieter Brinkman 27. April 2010 04:43

I use the following method to return a parent control of a specific type. This method is recursive and uses generics.

[code:c#]

private Control GetParentControl<T1>(Control control)
{
    if (control.Parent.GetType() == typeof(T1))
    {
        return control.Parent;
    }
    else
    {
        return GetParentControl<T1>(control.Parent);
    }
}

[/code]

Tags: , , , ,

ASP.Net | C# | Controls

MemoryStream to Byte Array (Byte[])

by Pieter Brinkman 19. April 2010 09:25

With the following code you can convert your MemoryStream to a Byte Array.

[code:c#]
//create new Bite Array
byte[] biteArray = new byte[memoryStream.Length];

//Set pointer to the beginning of the stream
memoryStream.Position = 0;

//Read the entire stream
memoryStream.Read(biteArray, 0, (int)memoryStream.Length);
[/code]

Tags: , ,

ASP.Net | C#

Gaatverweg.nl travelportal live

by Pieter Brinkman 7. April 2010 03:08

A few years after building the free travelblog site Globallog.nl in PHP. I started building a new version in .Net together with Mark. Although this was a joyful and educational experience, we never finished this project… Now a few years later I finished a new travelblog portal; Gaatverweg.nl.


Gaatverweg.nl is build with Wordpress MU (php) and uses multiple Wordpress plugins and a few custom build plugins.

Tags:

Portfolio

Powered by BlogEngine.NET 1.5.0.7
Theme by Mads Kristensen

About Me

My name is Pieter Brinkman I am Solution Architect for Sitecore in The Netherlands. My interests are mainly ASP.NET, MSSQL and Content Management Systems.

Calendar

<<  February 2012  >>
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
2728291234
567891011

View posts in large calendar

RecentComments

Comment RSS

Most comments