Tuesday 22 November 2011

Asp.Net: Get Text in RadEditor from Telerik

Question:
How do I get the html text of the Telerik RadEditor with JavaScript, jQuery?

Monday 26 September 2011

Asp.Net: Embed image in server control's assembly.

Question:
How to embed an image file  as an embedded resource in a server control assembly?
How to access an image from a server control assembly?

Asp.Net: Embed CSS in server control's assembly.

Question:
How to embed a CSS file in a server control assembly?
How to access style information (CSS) from a server control assembly?

Thursday 22 September 2011

Dot.Net: How to write RSS date format in CSharp

Question:
In a RSS feed I need to write dates in the format RFC #822. How do I do this?
How to write a string in the RFC 1123 format??

Wednesday 14 September 2011

Dot.Net: Generic List - test Subclass of IEnumerable

Question:
How to test if a given generic list type (e.g. List<>) implements an interface (e.g. IEnumerable<> or IEnumerable)?
How to check interface implementation for generic types? (IsSubclassOf does not work)

Tuesday 23 August 2011

Asp.Net: Generate PDF from Web Page

Question:
How to convert Html to PDF for a web page with wkhtmltopdf in asp.net ?
How to generate PDF from HTML using wkhtmltopdf in .net?

Asp.Net: Write Binary Stream to Response

Question:
How to send a Pdf binary stream as response of a web request?
How to return a generated pdf to the user in an asp.net app?

Friday 19 August 2011

Csharp: Regular Expressions Named Captures

Question:
How to use Named Capture Groups with C# Regular Expression class (Regex)?

Tuesday 16 August 2011

VisualStudio: Cheat Sheet CSharp Code Snippets


Question:
What are the common c# code snippets in Visual Studio 2010.

Wednesday 20 July 2011

SQL: Get random records from database

Question:
How to get a number of random records from a table.

Monday 18 July 2011

Dot.Net: Register WebResource Javascript from Different Assembly

Question:
I have a web control project and a web project.
In the web control project I embed a javascript file and declared it as a WebResource in the AssemblyInfo.cs:
[assembly: System.Web.UI.WebResource("Namespace.Folder.MyScript.js", "text/javascript", PerformSubstitution = false)].

When I want to use it from the web project using:
this.Page.ClientScript.RegisterClientScriptResource(this.GetType(), "Namespace.Folder.MyScript.js");
It does not work.
Why is the javascript file not loaded into the page?

Dot.Net: Loading UserControl ascx Dynamically

Question:
How to load a UserControl (ascx) dynamically?

Dot.Net: Make Internal Methods and Properties visible to another DLL

Question:
How to make internals visible to another dll?
I want to render my internals visible to a test class. How do I do that?

Wednesday 1 June 2011

Linq: Aggregate string array to string

Question:
I want to concatenate all strings of an array using Linq. How to?
How to use the aggregate method with enumerables of string?

Friday 20 May 2011

Asp.Net: Using Templated Controls Programmatically

Question:
How to add templates programmatically to a templated control?
How to programmatically set templates, events, databinding on a repeater in asp.net?

Sunday 8 May 2011

Dot.Net: How to Delete Accents from String

Question:
What is an easy way to delete accents from a string in CSharp ?
How to remove diacritic marks from characters in CSharp ?
How to remove accent marks from a string?
How to transform a string containing accents into a string without accents? (Each accented letter is transformed into its accent-less equivalent)

Thursday 5 May 2011

Dot.Net: Get Letter String from ASCII index

Question:
How to get the string for a given ASCII value in CSharp ?
How to write a list of letters from A to Z in a loop in c# ?

Dot.Net: Asynch Method Call Sample

Question:
Do you have an example of a standard asynchronous method call with callback in CSharp ?
Any event driven asynchronous sample in dot.net ??

Tuesday 3 May 2011

Dot.Net: Compare strings ignore case

Question:
How to compare two strings and ignore the case?
How to compare string upper and lower mixed?

Dot.Net: Unit Test VS2010 Write Output

Question:
How to write to console / output from a UnitTests method in Visual Studio 2010 ?

Wednesday 20 April 2011

Dot.Net: Set Property Value using Reflection

Question:
How can I set private properties of an object using reflection ?
How to set or get properties dynamically ?

Tuesday 19 April 2011

Dot.Net: Enum Samples

Question:
How do you handle enums in c#?

Monday 18 April 2011

Dot.Net: What are Enum Flags

Question:
What are Enum Flags?
What are Enums that work like Bit Flags?
How can an enum variable hold more than one (multiple) enum value?

Sunday 17 April 2011

SQL: Page data using Row_Number function

Question:
How to page through data on SqlServer 2005 (or later)?
Page through data on SqlServer 2005 using ROW_NUMBERfunction?

SQL: Find largest table in database

Question:
Who do I find the table with most rows for a given database in sql (SqlServer 2005)

Wednesday 13 April 2011

Dot.Net: Delegates and Actions

Question:
What is the difference between delegates and actions in csharp.

Tuesday 12 April 2011

Dot.Net: Break String to Words using Char.IsLetter(c) method

Question:
How do I split a string into words with csharp?
How can I decide whether a Unicode char is a letter or an alpha-numeric or not?

Monday 11 April 2011

Dot.Net: Singleton Pattern

Question:
What is a singleton?
How to implement a singleton in c#?
How do I make a singleton thread-safe?

Sunday 3 April 2011

Dot.Net: Calling Method Name for Logging

Question:
I want to log the name of the method that called me. How do I do this in c#?
How do I get the name of the caller method at a given execution point in dot.net?

Friday 1 April 2011

Dot.Net: Expose Custom Events

Question:
How do I expose custom events in a c# class?
How do I create custom event, event delegate, event arguments in dot.net?

Thursday 31 March 2011

Blogging: How to ping new blog posts

Question:
How do I ping my Blogger posts?
To which server and how do I ping my blog posts on Blogger?

Dot.Net: CurrentCulture vs CurrentUICulture

Question:
What is the difference between CurrentCulture and CurrentUICulture and when do I use which one in dot.net?
Should I use CurrentCulture or CurrentUICulture for localization (translation)?
Which culture should I use to parse dates or numbers in c#?

Monday 28 March 2011

Dot.net: AOP with PostSharp - Property accessor modified

Question:
How can I change a property getter for all my properties by using AOP?
How to use PostSharp, an Aspect Oriented Programming framework, to intercept property getter calls.

Dot.Net: Using Thread Local Storage

Question:
How to store and access thread specific static data in dot.net.
I want my static data not shared between different threads. How do I do this?

Tuesday 22 March 2011

Asp.Net: Order of HttpApplication events

 Question:
What is the order of the application events in a asp.net 4.0 application.
I have a HttpModule that subscribes to appliation events, in what order ?

Dot.Net: XML Serialization Sample

Question:
Do you have a standard XML serialization sample for dot.net?
How to serialize object to XML in dot.net?
What is the easiest way to transform objects to XML in dot.net?

Monday 21 March 2011

Dot.Net: XML Deserialize XElement

Question:
How do I deserialize a given string using XElement in dot.net??

Friday 18 March 2011

Asp.Net: Good Open Source Projects

Question:
What are the best open source projects for asp.net

Answer:
Don't know what are the best but here are some listed by crosoft:
Links to ASP.NET Open Source Projects

Saturday 5 March 2011

VisualStudio: Show Call Graph for method

Question:
How do I know the caller of my function?
Can I see the whole call graph in Visual Studio?

Tuesday 22 February 2011

Asp.Net: Simple HttpModule sample using Session

Question:
How do I create a HttpModule in asp.net ?
How do I get access to the Session in a HttpModule ?
Do you have a simple sample of a HttpModule in dot.net ?

Thursday 17 February 2011

Asp.Net: Add embedded Javascript to custom control

Question:
I'm building a custom web server control. How do I add embedded javascript code to my control?
How to load javascript from a custom control as Webresource?

Sunday 13 February 2011

Asp.Net: Generic Recursive FindControl Method

Question:
How to find a control in the whole page not just in the child collection?
How to find recursively a control in the child hierarchy of a control?

Saturday 12 February 2011

Asp.Net: Using ViewState to store data on the page.

Question:
How do I store data on a page during post-back round-trips?
How to use ViewState on pages?

Friday 11 February 2011

Asp.Net: Load HTML into Composite Web Server Control

Question:
How to load HTML into web server control?
How to build a composite server control from loaded Html in Asp.Net?
Create WebServerControls dynamically from Html.

Tuesday 8 February 2011

CSharp: How to use delegates

Question:
Why should I use delegates?
How to use a delegate?

Thursday 3 February 2011

Csharp: Using predicates as arguments.

Question:
How to pass predicates as arguments to my methods?
I want to use predicates as test methods and pass them to a general test.

CSharp: Get a List from an array

Question:
I have an array and need a list.
How do I transform the array into a list of objects?


Wednesday 2 February 2011

Csharp: measuring execution time of code blocks

Question:
How to mesure execution time of a method in csharp?
Measuring any time interval in dot.Net.


Friday 21 January 2011

Send generated excel on the web using HTTPReponse in dot.net

Problem:
You want to send a generated excel file as web response to the client.


Wednesday 19 January 2011

Execute a generic query on sql server.

Question:
Execute a generic query string on sql server.


Monday 17 January 2011

How to implement impersonation in an ASP.NET application

Question:
You want to impersonate the authenticating user only when you run a particular section of code.

Answer:
You must import [COM] advapi32.dll and use platform specific code.

Here is the microsoft article that describes different ways to implement impersonation in an ASP.NET application with sample code.

Impersonation in an ASP.NET application
Wednesday 12 January 2011

HTML: Entities or characters to encode in Html

Question:
What characters browsers do not like?
Do you have a list of entity code for common characters?

Monday 3 January 2011

Dump object state to string

Question:
I want to dump the members and properties of an object to the log to see the objects state.


Saturday 1 January 2011

Get dictionary of properties of a Type in CSharp

Question:
How do I get all public properties of a given type as a Dictionary?
How do I get properties of an object?
Get list of ProperyInfo for a given type.