CODEDIGEST
Home » Articles
Search
 

Technologies
 

Sponsored links
 

CodeDigest Navigation
 

Technology News
No News Feeds available at this time.
 

Community News
No News Feeds available at this time.
 
New Features in ASP.Net 4.0 - PART 2

By Bala Murugan
Posted On Aug 30,2009
Article Rating:
Be first to rate
this article.
No of Comments: 7
Category: ASP.Net 4.0
Print this article.

New Features in ASP.Net 4.0 - PART 2

In Part1 of this article series, we have seen the enhancements made on controlling viewstate, ClientID generation of server controls and some SEO enhancements in ASP.Net 4.0. Moving forward, we will see some more new features the ASP.Net 4.0 offers.

You can download the Visual Studio 2010 beta 1 and .net FX 4 from here.  To know more about downloading and installing newer version of Visual Studio, please refer here.

 

ListView control Improvements

ListView control is new databound control that is released in ASP.Net 3.5. To display data, we need to define 2 mandatory templates, LayoutTemplate and ItemTemplate. In ASP.Net 4.0 version, the LayoutTemplate is made optional and only defining ItemTemplate will display the data.

<asp:ListView ID="ListView1" runat="server"

        DataSourceID="SqlDataSource1" ClientIDMode="Predictable" ClientIDRowSuffix="EmpNo,EmpName">

        <ItemTemplate>

            <span style="background-color: #DCDCDC;color: #000000;">EmpNo:

            <asp:Label ID="EmpNoLabel" runat="server" Text='<%# Eval("EmpNo") %>' />

            <br />

            EmpName:

            <asp:Label ID="EmpNameLabel" runat="server" Text='<%# Eval("EmpName") %>' />

            <br />

            Address:

            <asp:Label ID="AddressLabel" runat="server" Text='<%# Eval("Address") %>' />

            <br />

            City:

            <asp:Label ID="CityLabel" runat="server" Text='<%# Eval("City") %>' />

            <br />

            Country:

            <asp:Label ID="CountryLabel" runat="server" Text='<%# Eval("Country") %>' />

            <br />

            <br />

           </span>

        </ItemTemplate>     

    </asp:ListView>

    <asp:SqlDataSource ID="SqlDataSource1" runat="server"

        ConnectionString="<%$ ConnectionStrings:ConnectionString %>"

        SelectCommand="SELECT * FROM [Employees]"></asp:SqlDataSource>

 

Empty Website project and Cleaner Web.Config file

Visual Studio 2010 includes a new project template to create empty ASP.Net 4.0 Web application project (Similar to Empty Website Template in older version).  These empty project templates will now include Web.Config file which is very clean and simple. Due to so many new additional features released, the web.config file is overloaded with information on handlers and modules (for asp.net ajax, etc). To maintain the Web.config easily, Visual Studio 2010 (from beta 2) includes only entries to identify the target framework used. Rest of the needed settings are moved to machine.config file.

 

Read more about this feature on Scott’s blog.

 

Routing in Webforms

Routing is a technique where asp.net webforms can be accessed with a friendly and descriptive URL’s.  Hence, the ugly URL’s with querystring can now be converted to a meaningful and descriptive which will be easy to remember and will improve the search engine rank.

Read Rangan’s post on routing here.

 

CSS Improvements

The other major improvements in ASP.Net 4.0 are on the way the HTML rendered to the client browser. The rendered HTML will be complaint with latest HTML standards.

Few things will be,

1.      A new property called controlRenderingCompatibilityVersion is added to the Pages element of configuration files.

<pages controlRenderingCompatibilityVersion="3.5|4.0"/>

 

The value “3.5” indicates the controls are rendered in legacy ways. The value “4.0” indicates the control will be rendered with the latest improvements of 4.0 framework.

2.      Till 3.5 framework, setting “Enabled=false” for any control will render disabled attributes in the HTML for the control. According to the latest HTML standard the disabled attribute should be set only for INPUT tags. ASP.Net 4.0 addresses this issue by rendering disabled attribute to only INPUT tags and a CSS class called “aspNetDisabled” to other controls to disable it when controlRenderingCompatibilityVersion property is set to “4.0”.

Below you can find a HTML rendered for a Label and TextBox control when controlRenderingCompatibilityVersion property is set to “4.0”.

<span id="Label1" class="aspNetDisabled">Label</span>

<input name="TextBox1" type="text" id="TextBox1" disabled="disabled" />

3.      From ASP.Net 2.0, the hidden fields generated for viewstate are packed inside a div tag for XHTML standard. This leads a small white space on the page. ASP.Net 4.0 now includes this div with a css class “aspNetHidden”. We can now define the class to prevent the white space by setting border to 0.

<div class="aspNetHidden">...</div>

4.      Menu controls render markup that is semantically correct and compliant with accessibility guidelines.

5.      Validation controls do not render inline styles.

 

RabioButtonList and CheckboxList Changes

From ASP.Net 4.0, the RadioButtonList and CheckBoxList controls includes 2 more value fro the property RepeatLayout.

1.      OrderedList

The radiobutton/checkbox is rendered as li elements within an ol element.

2.      UnorderedList

The radiobutton/checkbox is rendered as li elements within an ul element.

 




Improvements in Code Expressions

There is a new code expression syntax that is being shipped with ASP.Net 4.0.  We commonly use the following syntax to output a value from aspx page called code expression.

<%= HTMLOutput %>

 

There is a new code expression releasing with ASP.Net 4.0 version that will html encode the value.

<%: HTMLOutput %>

 

The above code expression will output the value after doing html encode. i.e. the above expression is equivalent to

<%= HttpUtility.HtmlEncode(HTMLOutput) %>

 

Permanent Redirection with HTTP 301 Moved Permanently Response

When we move our internet page to a different location, it is always required to send “HTTP 301 Moved Permanently” response to the search engines to hold back the page rank before redirecting to the new page. Understanding this need asp.net 4.0 includes a new method to do redirection called RedirectPermanent().

 

Refer below,

Response.RedirectPermanent("new url")

 

Conclusion

Thus, part 2 of this article series detailed on some of the enhancements the new framework brings for a webdeveloper. We will see more about other new features and enhancements in coming days.  Since, the current release is in beta there are chances that the above features may still have changes and improvements based on the community feedback. Download the newer version from here and you can submit your feedbacks/bugs at the visual studio support page. 

 

 

Similar Articles
You can contribute to CodeDiget.Com:
Donate to CodeDigest.com
Article Feedback
Comments
Thanks for being on
Thanks for being on point and on taergt! http://hzxmovb.com [url=http://rrpxrlij.com]rrpxrlij[/url] [link=http://rxyzuf.com]rxyzuf[/link]
Thought it <a href="
Thought it <a href="http://gkrybsaoo.com">woundl't</a> to give it a shot. I was right.
I thgouht finding th
I thgouht finding this would be so arduous but it's a breeze! http://lmqaufbu.com [url=http://gfanewb.com]gfanewb[/url] [link=http://hoolrvs.com]hoolrvs[/link]
If I were a Teenage
If I were a Teenage Mutant Ninja Turtle, now I'd say <a href="http://nqpflkvxl.com">"Kgnubawoa,</a> dude!"
If only there were m
If only there were more clveer people like you!
.NET 3.5 Button Subclasses
Please note that button subclasses that we use at my company, which were created in using .NET 3.5, had their classes overridden with "aspNetDisabled" when the button control was set to Enabled = False. You may need to set controlRenderingCompatibilityVersion to 3.5 when using subclasses controls compiled from .NET 3.5 projects.
Good Article !!
This is a good article to know about asp.net 4.0 features quickly. thanks.