n This tutorial we will learn about the MVC (Modal View Controller ) in ASP.Net
|
Here we will learn what all are the Asp.net MVC life cycle.
|
Here we will learn how to install IIS server in window 8 for this there are some steps for this installing this.
|
Here we will learn how to Install MVC and Check current MVC version in application
|
In this tutorial we will learn how to create a first MVC Application in asp.net mvc.
|
In this tutorial we will learn how to use controllers in an MVC application
|
Here we will learn about the action result and action method in Asp.net MVC.
|
In this tutorial we will See What are the different types of results in MVC
|
Here we will learn ASP.Net MVC Routing With Example
|
In this tutorial we will See Difference Between ViewResult and ActionResult in MVC.
|
In this tutorial we will See ViewData and ViewBag in Asp.Net mvc
|
In this tutorial we will See how to Access data from databse using Entity framework
|
Here we will See how to handle when Login failed for user IISpppool default apppool
|
In this tutorial we will See ActionLink Method in Asp.net MVC
|
Here we will See Use multiple View and tables in Asp.Net MVC
|
In this tutorial we will how to Use Business Library as Modal in Asp.Net MVC
|
Here we will learn how Insert Data into databas using Asp.Net MVC
|
In this tutorial we will how to Use UpdateModal and TryUpdateModal in Asp.Net MVC
|
Here we will learn Editing Modal and Update modal in Asp.Net MVC
|
In this tutorial we will how to Delete record from database using Asp.net MVC
|
Here we will learn how to perform CRUD Operation in Asp.Net MVC using Entity Framework
|
In this tutorial we will how to Customizing Autogenerated view in entityFramework in Asp.Net MVC
|
Here we will See Various Type Of Attribute in Asp.net MVC
|
In this tutorial we will how to Open a link in new browser window in Asp.net MVC
|
Here we will See Hiddeninput and readonly attributes in asp.net mvc
|
In this tutorial we will Display and edit templated helpers in asp.net mvc
|
Here we will learn how to create a Jquery calendar in asp.net MVC
|
In this tutorial we will learn how to Display Display a image in asp.net mvc
|
Here we will see Asp.Net MVC Membership Provider
|
In this tutorial we will learn how to Display Roles for the users in Asp.Net MVC Membership
|
Here we will see how to Assigning Role to User in Asp.Net MVC Membership
|
In this tutorial we will learn how to Remove Assigned Users from Role in Asp.Net MVC
|
Here we will what is Cross-site Request Forgery in Asp.Net MVC
|
In this tutorial we will see how to create Facebook authentication for ASP.NET MVC Wb Application
|
Here we will see how to create Twitter authentication for ASP.NET MVC Wb Application
|
Wednesday 20 May 2015
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”.
Subscribe to:
Posts (Atom)
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...