10 things to remember

5

Click here to load reader

Upload: sonia-merchant

Post on 16-Apr-2017

14 views

Category:

Education


0 download

TRANSCRIPT

Page 1: 10 things to remember

Developing Web App in Asp.net? DoRemember these 10 things

Many developers opt for ASP.NET MVC for their new webapplications. But this might not be always possible and you mayneed to use Web Forms for your new projects. That needs to befollowed certain guidelines while developing a Web Forms projectthen at later stage migrating to MVC would be less painfulcomparatively.

Here we have listed 10 key points to follow:

1. Use Class libraries

The evolution of .NET framework over the years depicts thatClass Libraries are best for coding that is independent of anyparticular type of UI. More the code is isolated in class libraries, itwould be possible in reusing them during and after the migrationwhich would be quite simple.

2. Use jQuery Ajax over Web Forms specific techniques

Web Forms aid AJAX Extensions to help develop Ajax-enabledapplications. Though these controls are specific to WebForms,instead of relying on them you may think of using standardAjax techniques such as jQuery $ .ajax() or XMLHttpRequestobject. Thus Ajax code will be quite portable to any other web

Page 2: 10 things to remember

development framework including MVC.

3. Make habit of using Web API

Though Web API was introduced along with MVC , now it’s a partof ASP.NET framework and Web API can be used in Web Formsapplications too, since Web API controllers will be 100% reusablein MVC applications.

4. Prefer to skip server control level UI properties

ASP.NET Web Forms make UI development quite easy. Just drag-n-drop controls set their properties and the UI is ready. Onecommon mistake most developer does is to set UI relatedproperties of the server controls. These properties are transformedinto style attribute of the respective control tag. A suggestedapproach is to place all such information in CSS style sheets andthen use Class Name property of the server controls to attach aCSS class.

5. Prefer to skip Web Forms specific features

Web Forms use several features that are Web Forms specific,which are not available in MVC. So avoid such features for newprojects because it will create difficulty during migration to MVCprojects.

6. Create forms without ViewState as much as possible

One big reservation which is against Web Forms is ViewState.Many Web Forms designers create their data entry pages in such away that multiple tasks happen on a single page. This may need

Page 3: 10 things to remember

page ViewState enabled resulting in bulky forms. You must see ifthese tasks can be separated in an attempt to avoid ViewStatealtogether.

7. Prefer to create reusable UI through User Controls

Developers have two choices for developing reusable userinterfaces – Web User Controls and Custom Server Controls. Ifyou wrap your reusable UI as a Web User Controls yourdevelopment will be easy. This is because there is raw HTML andcode and MVC offers a close equivalent in the form of partialpages.

8. Develop standard HTML over server controls whereverpossible

A Rich server control is one of the biggest strength of Web Formsapplications. Controls such as GridView and ListView are verypopular. But the usage might make your migration complicateddue to lack of direct equivalent in MVC. Though it’s not avoidablealtogether try to minimize their usage whenever possible. Forexample, if you don’t need to access Label controls duringprogramming, don’t use them. Use standard <span> or <lable>tags. This way we can reuse that much markup readily in MVC.

9. Understand in terms of MVC even for Web Formsapplications

Although Web Forms are not created keeping MVC design patternin mind, but that can’t stop you from thinking in MVC terms. Theseparation of concern as enforced by MVC can be done in WebForms also. So when you develop the Web Form try thinking in

Page 4: 10 things to remember

terms of its Model, Controller Actions and View.

10. Learn and use Design Patterns and SOLID principles

Many of us are habituated to drag-n-drop development. Ourapplications are UI centric. Though these applications might meetthe requirements at a given point of time, they becomes hard tomaintain and extend because a lot of code is stuffed directly intoWeb Forms.

Hope you liked the above discussion, let us know your opinion inthe comment section below.

If you are considering to learn ASP.Net and optimize yourselfin .NET training, then our CRB Tech .Net Training center wouldbe very helpful in fulfilling your aspirations. We keep ourselfupdated with the ongoing generation and that is being portrayed inour ASP.Net course.

Stay dropping to this page of CRB Tech reviews for moretechnical up-gradation and other resources.

Page 5: 10 things to remember