Saturday, May 28, 2011

How to Add validations controls Programmatically

I was looking for some server side validation message which can done without posting back to server. I tried doing javascript and writing that script to literal control and I have been thinking of doing a better way. But here is the cool way to do this.

// Dynamically adding Validation control
RequiredFieldValidator Validator = new RequiredFieldValidator();
Validator.ErrorMessage = "No data to download for your request.";
// Validation group must be specified as to which group you need to bind
Validator.ValidationGroup = "Group1";
Validator.IsValid = false;
Validator.Visible = false;
Page.Form.Controls.Add(Validator);

All you need to do is Depending on your need you need to change message and validation group. We need to set up validation group properly.


Happy coding Smile

Wednesday, May 18, 2011

How to add a ServiceThrottlingBehavior to a WCF Service?

When working with WCF especially when middle-tier client applications uses Windows Communication Foundation, you should always think about performance and take some major design decisions and tuning parameters.

By adding ServiceThrottlingbehavior in web.config we can achieve high performance using WCF. Below is the sample serivceThrottleconfiguration settings in web.config in .NET 4.0 Framework.

 <behaviors>
      <serviceBehaviors>
        <behavior name="CommonService">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
          <dataContractSerializer maxItemsInObjectGraph="2147483647" />
          <serviceThrottling maxConcurrentCalls="16" 
                             maxConcurrentInstances="116"   
                             maxConcurrentSessions="100"   />
        </behavior>
      </serviceBehaviors>
    </behaviors>

The main purpose for the throttling settings can be classified into the following two aspects:


  1. Controlled resource usage: With the throttling of concurrent execution, the usage of resources such as memory or threads can be limited to a reasonable level so that the system works well without hitting reliability issues.

  2. Balanced performance load: Systems always work in a balanced way when the load is controlled. If there are too much concurrent execution happening, a lot of contention and bookkeeping would happen and thus it would hurt the performance of the system.

In WCF 4, the default values of these settings are revised so that people don’t have to change the defaults in most cases. Here are the main changes:


  • MaxConcurrentSessions: default is 100 * ProcessorCount

  • MaxConcurrentCalls: default is 16 * ProcessorCount

  • MaxConcurrentInstances: default is the total of the above two, which follows the same pattern as before.

“ProcessorCount” is used as multiplier for the settings. So on a 4-proc server, you would get the default of MaxConcurrentCalls as 16 * 4 = 64. Thus the consideration is that, when you write a WCF service and you use the default settings, the service can be deployed to any system from low-end one-proc server to high-end such as 24-way server without having to change the settings. So CPU uses count as the multiplier.

Please note, these changes are for the default settings only. If you explicitly set these settings in either configuration or in code, the system would use the settings that you provided. No “ProcessCount” multiplier would be applied.

Tuesday, May 17, 2011

Web.config transformations in .NET 4.0

The web.config has now been refactored, and with ASP.Net 4 a lot of the settings that were previously found in the web.config file have now been moved to the machine.config file. This significantly reduces the size of the file, which I think is a great bonus.

Web.config transformations cater for moving your application between your relevant environments (e.g. DEV, QA, PROD). The transformations work on the relevant configurations you setup.
To create your own Configuration build with configuration transformations, create a new ASP.NET Web Application in Visual Studio 2010. Next, in the menu select "Build" and then "Configuration Manager". In the "Active Solution Configuration" drop down, select "New". Name the relevant configuration, for example I'm calling mine "DEV" and copying the settings from the "Debug" configuration.

Make sure "Create new project configurations" is selected. Once you click okay, you will see your Web.config file now has a "+" next to it in your solution explorer.

If you don't see the "+", build you solution, right click the web.config file and select "Add Config Transformations".
You will see for each of your build configurations there will be a "Web.[Build Configuration Name].config" file. If you open any of these files, you will see place holders for different sections of your original web.config file.

To change settings per your relevant build configuration, check out the following MSDN Article:Web.config Transformation Syntax for Web Application Project Deployment

Hope this helps.

Sunday, May 15, 2011

When to use .NET Framework Client Profile

The .NET Framework 4 Client Profile is a subset of the .NET Framework 4 that is optimized for client applications. It provides functionality for most client applications, including Windows Presentation Foundation (WPF), Windows Forms, Windows Communication Foundation (WCF), and ClickOnce features. This enables faster deployment and a smaller install package for applications that target the .NET Framework 4 Client Profile.

Check out following MSDN Page for Client Profile:.NET Framework Client Profile

How to Creating an HTML Signature in Outlook 2007

Here is the workaround to create HTML signatures for Outlook 2007. When you create a signature in Outlook 2007 it creates 3 separate files (.htm, .txt and .rtf). To create a more custom signature you can write it in HTML – this is especially useful for when dealing with graphics and advanced formatting.

How to create signature in Outlook 2007:

  1. In Outlook go to Tools > Options and the Mail Format tab.
  2. Click the Signatures button.
  3. Click the New button.
  4. Give your signature a name like ‘MySignature′
  5. Click on OK

Outlook doesn’t require any content to be added and will create the 3 individual files. Click OK and close Outlook

How to Locate your signature folder: Copy one of the following lines depending on what your operating system is.

  • Windows 7: %userprofile%\AppData\Roaming\Microsoft\Signatures
  • Vista: %userprofile%\AppData\Roaming\Microsoft\Signatures
  • XP-2003: %userprofile%\Application Data\Microsoft\Signatures

Click on Start and then Run – paste the line you copied into the Run box and hit Enter

You should see 3 files created for your "MySignature” file (in .htm, .txt and .rtf formats). If you can’t see the file extensions, go to Tools / Folder Options / View and untick ‘Hide extensions for known file types’, or right-click the file and select ‘Properties’ to determine the file type.

Replace the HTML file created by Outlook:
Take your HTML signature file and use it to replace the .htm file in your signature folder (i.e. save it as in this system folder, using the same filename as the .htm signature file created by Outlook ).

To start using your new signature:
Restart Outlook.

It worked for me on Outlook 2007 and Outlook 2010. Hope this is useful for you Smile

Wednesday, May 04, 2011

Remote Server Administration Tools for Windows 7

Remote Server Administration Tools for Windows 7 with SP1 enables IT administrators to manage roles and features that are installed on remote computers that are running Windows Server 2008 R2 with SP1 or Windows Server 2008 R2 (and, for some roles and features, Windows Server 2008 or Windows Server 2003) from a remote computer that is running Windows 7 or Windows 7 with SP1. It includes support for remote management of computers that are running either the Server Core or full installation options of Windows Server 2008 R2 with SP1, Windows Server 2008 R2, and for some roles and features, Windows Server 2008. Some roles and features on Windows Server 2003 can be managed remotely by using Remote Server Administration Tools for Windows 7 with SP1, although the Server Core installation option is not available with the Windows Server 2003 operating system.


This feature is comparable in functionality to the Windows Server 2003 Administrative Tools Pack and Remote Server Administration Tools for Windows Vista with Service Pack 1 (SP1).

Remote Server Administration Tools for Windows 7 with SP1 can be installed on computers that are running the Enterprise, Professional, or Ultimate editions of Windows 7 or Windows 7 with SP1. This software can be installed ONLY on computers that are running the Enterprise, Professional, or Ultimate editions of Windows 7 or Windows 7 with SP1; it cannot be installed on target servers that you want to manage.


Both x86- and x64-based versions of Remote Server Administration Tools for Windows 7 with SP1 are available for download on this page. Download and install the version that matches the architecture of the computer on which you plan to install the administration tools.

For more information go to MSDN for help. You can download this for 32 bit and 64 bit in the this URL.

Google SketchUp 8

Here are the features that Google is providing with this SketchUp software. Because almost everything is somewhere. By using this everyone can do 3D Modeling.

Whether you're designing in context, creating a shadow study or photo-modeling existing structures, SketchUp 8 provides easy access to Google's huge collection of geographic resources.

  • add-geo-location
    Model geo-location with Google Maps

    We've built Maps right into SketchUp. Adding a geo-location to your model is now an elegant, one-app process.

  • color-terrain
    Color imagery and more accurate terrain

    The snapshot you get when you add a geo-location to your model now includes 3D terrain data that's more accurate, and -- for the first time -- aerial imagery in color.

  • photo-match-improvements
    Match Photo improvements

    Our Match Photo feature lets you trace one or more photographs to build a model; it's an incredibly powerful tool. For SketchUp 8, we've tweaked some things to make using Match Photo easier than ever.

  • building-maker
    SketchUp, meet Building Maker

    When it comes to modeling existing buildings, it's hard to beat Google Building Maker for speed and efficiency. We've made it simpler to open and refine Building Maker models in SketchUp. Watch a video

    Watch a video about modeling in context with SketchUp 8

Download Google SketchUp 8