Search This Blog

Sunday, August 18, 2019

User Control and Custom Control Asp.net

User Control is a Container contain various Server Control and these control  use web page using drag and drop  extension is ascx

User Control  can create  individual assembly  but Custom Control create DLL and add VS tool box

Monday, August 5, 2019

Routing in MVC 4 and 5


  •  Routing  is a pattern matching system
  •  Routing maps incoming request (from browser) to a particular resource(controller and action   Method)
  Every Request come routing   match Route Table then  call particular  controller

 Route Table
  We define route for each action method
  All the routes  are stored in route table
  Each incoming request mapped to this route table




There are 2 type use Routing in MVC Application
Traditional Way
Attribute routing

                                                     Traditional Way

In  a traditional   way  routing define route particular file routeconfig.cs with in app-start folder
Routeconfig.cs  Code

   public class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                name: "allstudents",
                url: "students",
                defaults:new {controller= "Student" ,action= "GetAllStudent" }
             
           );
            routes.MapRoute(
                 name: "Students",
                 url: "students/{id}",
                 defaults: new { controller = "Student", action = "GetSingleStudent" },
                   constraints: new { id = @"\d+" }
            );
            routes.MapRoute(
              name: "StudentsAddress",
              url: "students/{id}/Address",
              defaults: new { controller = "Student", action = "StudentAddress" }
         );
         routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            );
           
        }
    }







Thursday, August 1, 2019

Difference between Static Constructors and Non-Static Constructors

A static constructor is used to initialize any static data, or to perform a particular action that needs to be performed once only. It is called automatically before the first instance is created or any static members are referenced.
class SimpleClass { // Static variable that must be initialized at run time. static readonly long baseline; // Static constructor is called at most one time, before any // instance constructor is invoked or member is accessed. static SimpleClass() { baseline = DateTime.Now.Ticks; } }

  • A static constructor does not take access modifiers or have parameters.
  • A class or struct can only have one static constructor.
  • Static constructors cannot be inherited or overloaded.
Non-static constructors are used to initializing the non-static members of the class

Times of Execution: A static constructor will always execute once in the entire life cycle of a class. But a non-static constructor can execute zero time if no instance of the class is created and n times if the n instances are created.

SQL Server Isolation Level

Read Committed
Read UnCommitted
Repeatable Read
Seriazable
Snapshot

Read Committed

READ Comitted  take only Committed value if any transaction pending or incomplete wait for till operation complete


Read Uncommitted

If any table is (updated Insert delete update) and transaction is waiting for complete or roll back  uncomitted  value display  it is called dirty read

if we want to read only committed rows use  keyword with(nolock)


  select * from Emp with(nolock)