public knowledge blog_load(sender Virendra)

                                                                                                                          Nothing shocks me, I am a Software Engineer.

Archive for the ‘ASP.NET 4.0’ Category

No need to type runat=”server” now

Posted by Virendra Dugar on June 1, 2009

If you are using Visual Studio 2005 or 2008, for every or Html control, you need to explicity write runat=”server” attribute. Sometimes I really wonder, why I have to write this attribute for every control as most of time I want to access controls on server side. Is n’t is tedious task? It should be added automatically. But it’s not possible with Visual Studio 2005 or 2008.

Well, we have a good news now. Now there is no need to type runat=”server“. It does not mean that It has been removed. Nope.. it’s get added automatically in VS 2010. Wow.. amazing..

In VS 2010, Microsoft has added hundereds of new code snippest for HTML, JavaScript and for ASPX.  If you want to place a textbox on the page, type tb and press Tab. Wow… You will see something like this..

<asp:TextBox ID="TextBox1" runat="server"/>

Type req and press Tab. Boom…

<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1" ErrorMessage="errormessage"></asp:RequiredFieldValidator>

There are lots of other code snippest almost for every control. Even for HTML tag also like table. Is n’t is cool?

Check out this video by Jeff king on new web development features of VS 2010.



Posted in ASP.NET 4.0 | Tagged: | Leave a 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 »

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 »

ASP.NET 4.0 Client ID Feature

Posted by Virendra Dugar on April 22, 2009

Hi All,

Check out this article on ASP.NET 4.0 Client ID Feature enhancement…..

Looks really cool….

Posted in ASP.NET, ASP.NET 4.0 | Tagged: | 2 Comments »

%d bloggers like this: