Wednesday, September 26, 2012

Difference between IList and List in c#

If you are exposing your class through a library that others will use, you generally want to expose it via interfaces rather than concrete implementations. This will help if you decide to change the implementation of your class later to use a different concrete class. In that case the users of your library won't need to update their code since the interface doesn't change.
If you are just using it internally, you may not care so much, and using List may be ok.

Tuesday, September 25, 2012

[required] Conditional Validation with Data Annotations in ASP.NET MVC4

When the user want some fields are Required some time’s . But some times  user don’t  Required some fields for example
In registration time  we want username and password field but  change password time only we want password field .In this situation we would create two models .To avoid this problem using removing the fields from the model state, it won’t be invalid when they are missing.  This method is simple and avoids adding additional dependencies.
    public class RegisterModel
        [Display(Name = "User name")]
        public string UserName { get; set; }

        [Display(Name = "Password")]
        public string Password { get; set; }
    public ActionResult ChangePassword()
        return View();


Monday, September 3, 2012

Razor View Engine

According to my knowledge has been two  view engine ‘s 
1) .aspx view engine
2) Razor view engine
. aspx view engine, which everyone knew about so let we describe the blog  Razor view engine
Razor was designed as an easy to learn, compact and expressive view engine that enables a fluid coding workflow. Razor file extension is ‘cshtml’ for C# language, and ‘vbhtml’ for Visual Basic. In existing .aspx view engine using the <%= %>  but
Razor view engine strats with @ it is very simpler,neat and light weight than aspx view engine
For example
Razor view engine
Todays date   @DateTime.Now

.aspx view engine
Todays date  <%= DateTime.Now %>
More about razor view engine refer scottgu  blog