Create an ASP.Net Core MVC application to populate a dropdown list. An application consists of model, view and controller.The controller will be responsible for selecting a view to be displayed to the user and provide necessary data model to retrieve and display data into the dropdown list. NO database will be used.
Create an ASP.Net Core MVC application to populate a dropdown list. An application consists of model, view and controller.The controller will be responsible for selecting a view to be displayed to the user and provide necessary data model to retrieve and display data into the dropdown list. NO database will be used.
Below is the desired output
In this question we have to create an ASP.Net Core MVC app dropdown list for selecting a view to display the user necessary data into the dropdown list | Asp.net core L1 assignment
After creating a new ASP.Net Core Web Application, there will be many folders as shown in the below image. You can also see that the code is successfully compiled without any error.
Here is the C# code for the HomeController.cs .
HomeController.cs
using Asp.net_Exercise_1.Models;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
namespace Asp.net_Exercise_1.Controllers
{
public class HomeController : Controller
{
private readonly ILogger<HomeController> _logger;
public HomeController(ILogger<HomeController> logger)
{
_logger = logger;
}
public IActionResult Index()
{
ViewBag.BooksSelectList = new Microsoft.AspNetCore.Mvc.Rendering.SelectList(GetBooks(), "Id", "Title");
return View();
}
private List<Books> GetBooks()
{
var books = new List<Books>();
books.Add(new Books() { Id = 1, Title = "Book 1" });
books.Add(new Books() { Id = 2, Title = "Book 2" });
books.Add(new Books() { Id = 3, Title = "Book 3" });
books.Add(new Books() { Id = 4, Title = "Book 4" });
return books;
}
}
}
Similarly, there are other folders also where there will be some C# code available.
OUTPUT:
The similar to the required output of the web application is as follows:
If you don't want to write codes or just want the result directly, here I have provided all the code files also(zip).
No need to do anything, you just have to open the provided file in Visual Studio 2019 and compile this.
Click to get the code in Zip File |
No need to write anything for output just unzip the folder and open it in Visual Studio 2019 and click on .sln file then run the HomeController.cs code, you will get the desired output.
Here you can see in the zip file there will be all these files available, you don't have to do anything just follow the above instructions.
You can download the zip file from here , click on the below image.
___________________________
Create an Asp.Net MVC Application. The application is a simple online store which allows users browsing through a catalog of shirts, mugs, and other items in a below given format.
In this article i will provide you the Asp.net Core L1 assignment solution.
In this question we have to create an Asp.net Core MVC application code for online store which allows users browsing through a catalog of shirts, mugs, and other items | Asp.net core L1 assignment.
After creating a new ASP.Net Core Web Application, there will be many folders as shown in the below image. You can also see that the code is successfully compiled without any error.
Here is the C# code for the Index.cshtml.
Index.cshtml code
@*
ViewData["Title"] = "Home Page";
*@
<html>
<head>
</head>
<body>
<div class="background">
<div class="mainbox">
<div class="mainbox1">
<div style="margin-left: 27px; font-weight: 600;">BRAND</div>
<select class="dropdown">
<option value="">All</option>
<option value="">Option1</option>
<option value="">Option2</option>
</select>
</div>
<div class="mainbox1">
<div style="margin-left: 27px; font-weight: 600;">TYPE</div>
<select class="dropdown">
<option value="">All</option>
<option value="">Option1</option>
<option value="">Option2</option>
</select>
</div>
<div class="mainbox1">
<button class="button">
<span style="color: white; font-size: 29px; font-weight: bold;">></span>
</button>
</div>
</div>
</div>
<div>
<div style="width:70%;text-align:center;float: left;padding: 9px 0 0 184px;">Showing 10 of 12 products - Page 1-2</div>
<div class="next">
<a href="#">Next</a>
</div>
</div>
<div>
<div class="box1">
<img src="https://th.bing.com/th/id/OIP.STu3eRACqMTlWoWB4m9lDwHaJ4?pid=ImgDet&rs=1"/>
<button class="addtocart" href="#">[ADD TO CART]</button>
<h1>Stylish Hoddie<br />
Rs.1599</h1>
</div>
<div class="box1">
<img src="https://th.bing.com/th/id/R916fa5f6c52085867a8b5e3629002a06?rik=bUMDw5Q79Vtv2A&riu=http%3a%2f%2fwww.iwgac.com%2fimages%2fdetailed%2f27%2f049-1514C.jpg&ehk=wEA1UDWWsIWpzXS91NMQx2wbQXSoLQMSppCS7psHEhA%3d&risl=&pid=ImgRaw" />
<button class="addtocart" href="#">[ADD TO CART]</button>
<h1>Coffee Cup<br />
Rs.359</h1>
</div>
<div class="box1">
<img src="https://th.bing.com/th/id/R85d6b7a3d7e7fcc4db680956029970d3?rik=klcifSmBRwvJCw&riu=http%3a%2f%2fwww.prodirectsoccer.com%2fproductimages%2fV3_1_Main%2f160017.jpg&ehk=N%2fZ4SmSYIQGe5ybRqdWJs96figGEMv%2bR0mq0nCIrrIU%3d&risl=&pid=ImgRaw" />
<button class="addtocart" href="#">[ADD TO CART]</button>
<h1>White Nike T-Shirt<br />
Rs.669</h1>
</div>
</div>
</body>
</html>
Similarly, there are other folders also where there will be some C# code available.
OUTPUT:
The similar to the required output of the web application is as follows:
If you don't want to write codes or just want the result directly, here I have provided all the code files also(zip).
No need to do anything, you just have to open the provided file in Visual Studio 2019 and compile this.
Click to get the code in zip file |
No need to write anything for output just unzip the folder and open it in Visual Studio 2019 and click on .sln file then run the Index.cshtml code, you will get the desired output.
Here you can see in the zip file there will be all these files available, you don't have to do anything just follow the above instructions.
You can download the zip file from here , click on the below image.
____________________________
Comments
Post a Comment