Wednesday 20 May 2015

Asp.Net MVC Tutorials

What Is MVC in Asp.Net

n This tutorial we will learn about the MVC (Modal View Controller ) in ASP.Net

Asp.net MVC life cycle

Here we will learn what all are the Asp.net MVC life cycle.

how to install IIS server in window 8

Here we will learn how to install IIS server in window 8 for this there are some steps for this installing this.

Install MVC and Check current MVC version in application

Here we will learn how to Install MVC and Check current MVC version in application

how to create a First MVC Application

In this tutorial we will learn how to create a first MVC Application in asp.net mvc.

How to use controllers in an MVC application

In this tutorial we will learn how to use controllers in an MVC application

Action result And Action Method in MVC

Here we will learn about the action result and action method in Asp.net MVC.

What are the different types of results in MVC

In this tutorial we will See What are the different types of results in MVC

ASP.Net MVC Routing With Example

Here we will learn ASP.Net MVC Routing With Example

Difference Between ViewResult and ActionResult in MVC.

In this tutorial we will See Difference Between ViewResult and ActionResult in MVC.

View in asp.net MVC

Here we will learn View in asp.net MVC

ViewData and ViewBag in Asp.Net mvc

In this tutorial we will See ViewData and ViewBag in Asp.Net mvc

Modal in Asp.Net MVC

Here we will See Modal in Asp.Net MVC

Data Access from databse using Entity framework

In this tutorial we will See how to Access data from databse using Entity framework

Login failed for user IISpppool default apppool

Here we will See how to handle when Login failed for user IISpppool default apppool

ActionLink Method in Asp.net MVC

In this tutorial we will See ActionLink Method in Asp.net MVC

Use multiple View and tables in Asp.Net MVC

Here we will See Use multiple View and tables in Asp.Net MVC

Use Business Library as Modal in Asp.Net MVC

In this tutorial we will how to Use Business Library as Modal in Asp.Net MVC

Insert Data into databas using Asp.Net MVC

Here we will learn how Insert Data into databas using Asp.Net MVC

UpdateModal and TryUpdateModal in Asp.Net MVC

In this tutorial we will how to Use UpdateModal and TryUpdateModal in Asp.Net MVC

Editing Modal and Update modal in Asp.Net MVC

Here we will learn Editing Modal and Update modal in Asp.Net MVC

Delete record from database using Asp.net MVC

In this tutorial we will how to Delete record from database using Asp.net MVC

CRUD Operation in Asp.Net MVC using Entity Framework

Here we will learn how to perform CRUD Operation in Asp.Net MVC using Entity Framework

Customizing Autogenerated view in entityFramework in Asp.Net MVC

In this tutorial we will how to Customizing Autogenerated view in entityFramework in Asp.Net MVC

Various Type Of Attribute in Asp.net MVC

Here we will See Various Type Of Attribute in Asp.net MVC

Open a link in new browser window in Asp.net MVC

In this tutorial we will how to Open a link in new browser window in Asp.net MVC

Hiddeninput and readonly attributes in asp.net mvc

Here we will See Hiddeninput and readonly attributes in asp.net mvc

Display and edit templated helpers in asp.net mvc

In this tutorial we will Display and edit templated helpers in asp.net mvc

Jquery calendar in asp.net MVC

Here we will learn how to create a Jquery calendar in asp.net MVC

Display a image in asp.net mvc

In this tutorial we will learn how to Display Display a image in asp.net mvc

Asp.Net MVC Membership Provider

Here we will see Asp.Net MVC Membership Provider

Display Roles for the users in Asp.Net MVC Membership

In this tutorial we will learn how to Display Roles for the users in Asp.Net MVC Membership

Assigning Role to User in Asp.Net MVC Membership

Here we will see how to Assigning Role to User in Asp.Net MVC Membership

Remove Assigned Users from Role in Asp.Net MVC

In this tutorial we will learn how to Remove Assigned Users from Role in Asp.Net MVC

Cross-site Request Forgery in Asp.Net MVC

Here we will what is Cross-site Request Forgery in Asp.Net MVC

Facebook authentication for ASP.NET MVC Wb Application

In this tutorial we will see how to create Facebook authentication for ASP.NET MVC Wb Application

Twitter authentication for ASP.NET MVC Wb Application

Here we will see how to create Twitter authentication for ASP.NET MVC Wb Application

ActionLink Method in Asp.net MVC

Here we will discuss about action Link Method in Asp.net MVC. Action Link method is a HTML helper which is used to provide the hyperlink. So Here we will generate hyperlink using ActionLink HTML helper for navigation b/w MVC pages.
Here we will show all the student name as Bullet List with the hyper link  when we click on that hyper link it should show respective student details.
Before coming in this tutorial please read previous tutorial.

Step(1).:-  In previous tutorial we have a Controller class name is “StudentController.cs” ther e we have a StudentDetail method for showing Student detail.  
Now we need a another method for showing Student name with the hyperlink, So for that add a another method to this class.
using System.Web.Mvc;
using MvcApplication1.Models;

namespace MvcApplication1.Controllers
{
    public class StudentController : Controller
    {

        public ActionResult Index()
        {
            StudentContext _context = new StudentContext();
            List<Student> _students = _context._studentDb.ToList();

            return View(_students);
        }
       
        public ActionResult StudentDetail(int id)
        {
            StudentContext _context = new StudentContext();
           Student _student =  _context._studentDb.Single(c => c.StudentId == id);

            return View(_student);
        }

    }
}



Step(2):-  We have View for StudentDetail method but we don’t have method for Index method so for index method create a View , For creating a view for index method right click on that method and add a method. Here you select Strongly typed view as Student from dropdownbox.



Step(3):-  After click on Add it will  add a view with the name as “Index.cshtml”. So you write following code in View



@model IEnumerable<MvcApplication1.Models.Student>

@using MvcApplication1.Models;
@{
    ViewBag.Title = "Student Names";
}
<div style="font-family: Arial">
    <h2>Student Names</h2>
    <ul>
    @foreach (Student _student in @Model)
    {
    <li>
    @Html.ActionLink(_student.StudentName,"StudentDetail",new {id = _student.StudentId})
   
    </li>
    }
    </ul>
</div>



Step(4) : Go to another StudentDetail View and add a link there also for coming back in Index view.



@model MvcApplication1.Models.Student

@{
    ViewBag.Title = "StudentDetail";
}

<h2>StudentDetail</h2>

<table style="font-family:Arial">
    <tr>
        <td>
            Student ID:
        </td>
        <td>
            @Model.StudentId
        </td>
    </tr>
    <tr>
        <td>
            Name:
        </td>
        <td>
            @Model.StudentName
        </td>
    </tr>
    <tr>
        <td>
            Gender:
        </td>
        <td>
            @Model.Gender
        </td>
    </tr>
    <tr>
        <td>
            City:
        </td>
        <td>
            @Model.SchoolName
        </td>
    </tr>
</table>

@Html.ActionLink("Back To Student Name List", "Index")


Step(5):- Now Run your application and navigate to following URL  the O/p Will be
http://localhost/MvcApplication1/student


Step(6):-  When you will click  on Name it will go to “StudentDetail” View with Respective ID.



For Index View or Student List click on “Back To Student Name List”.

C# program Selection Sorting

Selection sort is a straightforward sorting algorithm. This algorithm search for the smallest number in the elements array and then swap i...