public knowledge blog_load(sender Virendra)

                                                                                                                          Nothing shocks me, I am a Software Engineer.

Archive for May, 2009

ASP.NET Best Practices

Posted by Virendra Dugar on May 29, 2009

Check out these articles that explains the best pratices for ASP.NET to improve application performance.



Posted in ASP.NET | Tagged: | 1 Comment »

ASP.NET 4.0 : ListView Control Enhancements

Posted by Virendra Dugar on May 27, 2009

The ListView control, which was introduced in ASP.NET 3.5, has all the functionality of the GridView control while giving you complete control over the output. This control has been made easier to use in ASP.NET 4.0. The earlier version of the control required that you specify a layout template that contained a server control with a known ID. The following markup shows a typical example of how to use the ListView control in ASP.NET 3.5.

 <asp:ListView ID="ListView1" runat="server">
     <asp:PlaceHolder ID="ItemPlaceHolder" runat="server"></asp:PlaceHolder>
     <% Eval("LastName")%>

In ASP.NET 4.0, the ListView control does not require a layout template. The markup shown in the previous example can be replaced with the following markup:

<asp:ListView ID="ListView1" runat="server">
     <% Eval("LastName")%>

Posted in ASP.NET, ASP.NET 4.0 | Tagged: | Leave a Comment »

ASP.NET 4.0 : FormView Control Enhancements

Posted by Virendra Dugar on May 22, 2009

The FormView control is data-bound control that is nothing but a templated version of DetailsView control is designed to give you full control over the rendered markup. Bydefault, FormView control gets rendered as HTML table.  Consider this example :

<asp:FormView ID="FormView1" runat="server">
    Content goes here!

This gets rendered like :

<table cellspacing="0" border="0" id="FormView1" style="border-collapse:collapse;">
    <td colspan="2">
        Content goes here!

ASP.NET 4.0 comes with new property RenderTable which lets you specify whether the FormView control renders using a table.  This is how you specify it..

<asp:FormView ID="FormView1"runat="server" RenderTable="false">

If this property is used with previous example then the output will be without table, tr and td tag:

Content goes here!

This enhancement can make it easier to style the content of the control with CSS, because no unexpected tags are rendered by the control..


Posted in ASP.NET 4.0 | Tagged: | Leave a Comment »

New release of the Ajax Control Toolkit

Posted by Virendra Dugar on May 18, 2009

A new version of Ajax control toolkit is now available from the codeplex web site. The version is 3.0.30512.  3 new much awaited controls are introduced.

  1. HTMLEditor
    The HTMLEditor control allows you to easily create and edit HTML content. You can edit in design mode, as a rich text editor, or in source view to edit the HTML markup directly.
  2. Combobox
    The ComboBox control provides a DropDownList of items, combined with TextBox. Different modes determine the interplay between the text entry and the list of items.
  3. Color Picker
    The ColorPicker Control Extender can be attached to any ASP.NET TextBox control. It provides client-side color-picking functionality with UI in a popup control.

Check out the live demo of these control on the sample site.

Just a Note :- The current version of the AJAX Control Toolkit is not compatible with ASP.NET 2.0. It’s only compatible with ASP.NET 3.5 Service Pack 1 or later version.


Posted in Ajax Control Toolkit | Tagged: | Leave a Comment »

ASP.NET 4.0 : ViewStateMode (New Property)

Posted by Virendra Dugar on May 17, 2009

ViewState is a very misunderstood animal. ViewState is a headache for the programmers. Programmers leave it enable for all the controls even if there is no need to persist their value. Right use of ViewState can increase the performance of the page drastically.

Before I discuss about this new property, let’s come back to the current era of ASP.NET 3.5 or previous version of .NET. What if you turn off ViewState at page level and make it on at control level? Ask yourself, is it possible with previous versions of .NET (upto 3.5)? Sorry but there is a bad news that it’s not possible. But there is a good news as well. You can achieve this with new version of ASP.NET that is 4.0.

ASP.NET 4.0 comes with new and cool property ViewStateMode. It has 3 possible values.

  1. Enabled : This turns on the ViewState for the control.
  2. Disabled : This turns off the ViewState for the control.
  3. Inherit : Takes the value from the parent and set it accordingly. If it has been set to Disabled at Page level and for textbox you set ViewStateMode = “Inherit” then it will disable the ViewState for the textbox.

The main difference between EnableViewState and ViewStateMode property is, if EnableViewState property is set to disabled at parent level, there is no way of making viewstate enable at control level, But this is possible with this new property :ViewStateMode.

It’s really cool and simple.. is n’t it? 


Posted in ASP.NET 4.0 | Tagged: | Leave a Comment »

C# 4.0 Features

Posted by Virendra Dugar on May 7, 2009

As we all know, .NET 4.0 is around the corner so as C# 4.0. As we know, each version of C# was introduced with some major features. For example, C# 1.0 major feature was managed code. In C# 2.0, Generics were introduced. In C# 3.0, Automatic properties, object initializer, collection initializer and LINQ were launched. C# 4.0 comes with these major feartures:

  1. Dynamic LookUp
  2. Named and optional argument (Much needed)
  3. Improved COM interoperability
  4. Co and Contra Variance

You can download a document related to new features of C# 4.0 from MSDN website. This document explains all the above features.

You can also check this article on Code project.


Posted in ASP.NET 4.0, C# | Tagged: , | Leave a Comment »

Blank Subject Warning For Outlook 2007

Posted by Virendra Dugar on May 1, 2009

Nowdays, In Professional world outlook is used as email client. Subject line is very important part of any email. A good subject line can drive the attention of the email reader. How many times it happend with you that you have sent an email through outlook without a subject line. After clicking the send button you realize that you have made mistake. Are you forgetting to include the subject line? As outlook does not validates for empty subject line.

Well follow these steps to validate the empty subject line for Outlook 2007.

1.  Go to Tools -> Macro -> Visual Basic Editor. Or Directly press Alt + F11.

Step 1

2. Visual basic editor window gets opened.

3.  On the Left Pane, You can see “Microsoft Outlook Objects” or “Project1″, expand this. Now you can see the “ThisOutLookSession”.

Step 2

4. Double click on “ThisOutLookSession”. It will open up a code pane.

5. Copy and paste the following code in the code pane.

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim strSubject As String
strSubject = Item.Subject
If Len(Trim(strSubject)) = 0 Then
Prompt$ = "Subject is Empty. Are you sure you want to send the Mail?"
If MsgBox(Prompt$, vbYesNo + vbQuestion + vbMsgBoxSetForeground, "Check for Subject") = vbNo Then
Cancel = True
End If
End If
End Sub

Step 3

Now, just save the project.

One more setting you need to do and that is to enable macro.
Go to Tools->Macro->Security. A dialog window gets opened. Select Warning for all macro option.

Step 4

That’s it.. You are good to go now.

Close your outlook and open it again. You will be asked regarding the security concern. See the image below.

Step 5

Click on Enable Macros.

Now try to send a mail with empty subject line.


Posted in Outlook | Tagged: | Leave a Comment »

%d bloggers like this: