Monday, 23 March 2015

MVC routing

MVC routing

MVC routing is the URL is mapped to controller and controller is mapped to any action type.
Suppose there is the control name customer where the action is  DisplayCustomer and you are checking in the local host than the URL will form as  http://localhost/ customer/ DisplayCustomer
Now lets see where the Routing configuration defined for MVC project.
You can see the below folder structure for Your MVC project and on it there is a file RouteConfig.cs



Friday, 20 March 2015

c# hashtable vs dictionary

Hashtable and Dictionary both of them are used to maintain the key, value pair only there is some basic difference that makes us to opt, any of this 2 based on the situations.

Differences  between Hashtable and Dictionary.

1.       Declaration of Hashtable and dictionary;
Dictionary:
Dictionary<int, string> dict = new Dictionary<int, string>();

Hashtable :
Hashtable hst = new Hashtable();

convert list to string c#

There are many ways you will do convert list to string c# from google. But what you will adopt, which is good in terms of line and in terms of complexity.

 I will demonstrate three ways to convert list to string c# with “,” seperated  and you will see that which one is taking less time in execution.
Suppose you have list of sting, that you can form like below code; Having 1Lakhs of string records


Thursday, 5 March 2015

mvc pass model into view

Just create the simple MVC Application and you have structure Like Below screen;


Now you can see that we don’t have Models file in the structure. Now Create a Department class and the model which will have 3 Entity :

showing viewdata in MVC 5 on razor view

In MVC Viewdata is the way to maintain the data for passing it  from Controller to View.

Just giving the below example to pass the ViewData in MVC5 on Razor View;

You have defined or pass the Viewdata from controller like below;

public class HomeController : Controller
    {
        //
        // GET: /Home/
        public ActionResult Index()
        {
            return View();
        }

        public ActionResult MyHomeview()
        {
            ViewData["Datetime"] = DateTime.Now.ToString();
            return View();
        }
       }

Others

You will like to read it