Tuesday, October 30, 2018

Page life cycle of MVC

Below are the processed followed in the sequence -
→App initialization
→Instantiate and execute controller
→Locate and invoke controller action
→Instantiate and render view.

Thursday, October 11, 2018

EF 6 Code-First Conventions

 Conventions  are the default rules which automatically configure a conceptual model.

Tuesday, October 9, 2018

Create Connection With Store Procedure with MySql in c#

MySqlConnection con = new MySqlConnection("server=YourServerName;port=3306;
database=yourdbname;uid=youruid;pwd=your PWD;");
string firstparanamevalue="Your Value";
string secondparanamevalue="Your Value";
MySqlCommand cmd1 = new MySqlCommand();
cmd1 = con.CreateCommand();
cmd1.CommandText = "YourProcedureName";
cmd1.CommandType = CommandType.StoredProcedure;
cmd1.Parameters.AddWithValue("firstparaname", firstparanamevalue);
cmd1.Parameters.AddWithValue("secondparaname", secondparanamevalue);

If Any Problem Please Comment.

Confirmation in Window Form in c#

var confirmResult = MessageBox.Show("Click 'Yes' To Close or 'No' to Cancel ??","Confirm To Close!!",MessageBoxButtons.YesNo);

            if (confirmResult == DialogResult.Yes)
              //Your Code

Action Filter in MVC

Whenever A user request is routed to a controller there may be a need to execute some logic before or after execution of particular operation ,For Achieving this ASP .Net provides functionality Called Action Filter.

Types of Filters

1. Action Filter :

      Action filter is a logic which execute after and before a controller action executes.

2. Authorization Filter :

       Authorization filter is used to implement authentication and  Authorization on controller action.

3. Result Filter :

       Result Filter is used to execute after and before view result is executed.

4. Exception Filter

        Exception Filter are used to handle errors raised by your controller and controller result.

Wednesday, September 19, 2018

Autocmplete Text Box in mvc using entity framework with some extra information.

On View:

<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/start/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
            source: function (request, response) {
                    url: "/AppointmentList/customerlist",
                    type: "POST",
                    dataType: "json",
                    data: { searchtxt: request.term },
                    success: function (data) {
                        response($.map(data, function (item) {
                            return { label: item.Name, value: item.Name, id: item.CustomerID };

            messages: {
                noResults: "",
                results: function (count) {
                    return count + (count > 1 ? ' results' : ' result ') + ' found';
            select: function (e, i) {

On Controller:


        public JsonResult customerlist(string searchtxt)
            var customerlist = crmapp.customers.Where(x => x.Name.StartsWith(searchtxt.ToLower()));
            return Json(customerlist, JsonRequestBehavior.AllowGet);

Monday, September 17, 2018

Swap two Number without using 3rd variable in c#:

            int a = 1, b = 2;
            Console.WriteLine("Before Swapping :"+a + "," + b);
            a = a + b;
            b = a - b;
            a = a - b;
            Console.WriteLine("After Swapping :" + a + "," + b);