Custom Search
Showing posts with label asp.net. Show all posts
Showing posts with label asp.net. Show all posts

August 27, 2008

ASP.Net MVC Framework Introduction

MVC stands for Model - View - Controller and is an architectural pattern used in software engineering. Successful use of the pattern isolates business logic from user interface considerations, resulting in an application where it is easier to modify either the visual appearance of the application or the underlying business rules without affecting the other.


Model

Used to accessing, retrieving, using, and maintaining data.

View

Used for displaying all the data.

Controller

Used to handle things from View to Model and From Model to View. The interaction between View and Model happens in the Controller.

Release History:

  • ASP.NET MVC Framework ( December 10, 2007)
  • ASP.NET MVC Preview 2 ( March 5, 2008 )
  • ASP.NET MVC Preview 3 ( May 1, 2008 )
  • ASP.NET MVC Preview 4 ( July 16, 2008 )
  • ASP.NET MVC Preview 5 ( August 28, 2008 )
  • ASP.NET MVC Beta ( October 16, 2008 )
  • ASP.NET MVC Release (expected to be released on, January, 2009)

ASP.NET MVC Official Website

March 3, 2008

User Controls for Reusable Forms

ASP.NET Web User Controls are very useful to minimize the development time of a project. It helps to reuse the codes all over again without recoding it. Image if you created a code that has 1000 lines and used in two tables. This would take you to change about 50%-80% of your codes in the second table. However, if you used Web User Controls, you will only need to change/set the property you want and takes you more or less 10% total time to put it in the second table. Another advantage of User Controls is that if you change anything in the code, you don't need to change all the other similar codes, all the others will automatically changed.

STANDARDIZATION NOTES:
  • You must use User Controls if that code can still be used in other forms.
  • If the query varies but the results are still the same usage of User Control is Recommended.
Example:
Create a blogging table. Blogs will be differentiated as Draft and Published. All Unregistered Users can only view all the blogs published by all Registered Users. Registered user can still view all published blogs by all users but has a management page where he/she can view all his blog work may it published or still a draft. Draft Blogs are in one table and Published Blogs are on the other table.

In this example there are three queries, the All Published (AP), Published by User (PU), and Drafted by User (DU). There is also one table, the blogging table (BT) but will be use for three times, in the Blog page, Management Page Draft area, and Management Page Published area. To save development time it is obvious to use the ASP.NET Web User Control. However there three different queries that we must follow. To solve this we must have a User Control Property that determines what query to be used. You can create an Enumeration to be represent those queries.

public enum QueryType{ AllPublished, Drafted, Published, None } //None Represents nothing was selected and returns nothing.

To set the Property:

public QueryType ViewBlog{
set{

if (value == QueryType.AllPublished){
//Do the query here
}

else if (value == QueryType.Published){
//Do the query here
}

else if (value == QueryType.Drafted){
//Do the query here
}

}
}

If you add this User Control in the web page and look at its property, you will see another property (ViewBlog) in the MISC property. Use this property to set the values of the User Control.


February 27, 2008

ASP .Net Database Access Layer Standards

In a professional ASP.Net programming world, an IT company should have standards on how to access the database on every programming tasks they have. We have already determined the SQL Database Standards. Now we need to determine how to access and use it in our ASP.Net Projects. But first we need to point out the following words:

  • Datasets - a collection of DataTable objects that you can relate to each other with DataRelation objects. (MSDN)
  • Database Factory - it is a compilation of codes which is used to access the database. Those functions/methods involved in the codes can be used all over again, thus, boosting the productivity of a programmer.
  • Data Sources - is a representation of data.