How to profile asp.net web application with DotTrace

If your application works slow and you can’t understand why, than have a look at dotTrac. It’s a very good tool from JetBrains. It helps you to profile both windows and web application written in c#.

Profile web application is very easy. After starting dotTrace you have to select “Profile Application”.

New window appears [...]

How to use curly brackets inside of String.Format

String.Format provides inserting variables inside of the string, indicated with curly brackets and index, for example

String s = string.Format"Hello {0}", name)

But if you need to use curly brackets inside of string format you will get exception, because compiler does not know if you trying to insert curly bracket or replacing string. So you can get [...]

Tiny MCE ASP.NET and RequiredFieldValidator

To make validator work wity Tiny MCE, you need to update textarea before the validation starts. To update it, call tinyMCE.triggerSave(false, true) method in your button event.

<asp:Button runat="server" ID="BtnCommit" <br />OnClick="BtnCommit_Click" CssClass="buttonclass" <br />Text="Submit" style="float:right;"<br /> OnClientClick="tinyMCE.triggerSave(false,true);"/>

Installing Silverlight 2 Tools on machine with proxy.

Today I tried to install Silverlight tools on my machine, but it works using proxy server, so installation failed because installer can’t find my proxy settings.

To fix it I have to install all of the components manually

The items you have to download are:

1. Silverlight 2 for developers

2. Start installer.

3. Go to the C:\ drive and [...]

LINQ to object vs foreach

My learning LINQ begins with a question: Why I have to use it?
The same job can be done with the foreach cycle, so I created a simple test to find out what is quickly.

Random rnd = new Random();
List< string > names = new List< string >();
for ( int i = 0; i < 1000000; i++ [...]

How to read data from app.config?

It’s simple,
Just use ConfigurationManager class

<?xml version=”1.0″ encoding=”utf-8″ ?>
<configuration>
<appSettings>
<add key=”ApplicationPath” value=”C:\MyProjects\TestProject\”/>
</appSettings>
</configuration>

And to read data use this code

public static string AppPath()
{
return ConfigurationManager.AppSettings["ApplicationPath"];
}

Do not forget add reference to the System.Configuration