10
1
using System;
2
using System.ComponentModel.DataAnnotations;
3
4
namespace HelloWorldMvcApp
5
{
6
public class SampleViewModel
7
{
8
9
}
10
}
48
1
<!DOCTYPE html>
2
<html>
3
<head>
4
<title>ImageShapes</title>
5
<script src="https://code.jquery.com/jquery.min.js"></script>
6
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
7
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
8
<meta charset="utf-8">
9
</head>
10
<body>
11
12
@using (Html.BeginForm())
13
{
14
<div class="container">
15
16
17
<h2>ImageShapes</h2>
18
19
Choose ImageShapes:
20
@Html.DropDownList("ImageShape",
21
(SelectList)ViewBag.ImageShapesList,
22
"N/A",
23
new {
24
28
1
using System;
2
using System.Web.Mvc;
3
using System.Collections.Generic;
4
5
namespace HelloWorldMvcApp
6
{
7
public class HomeController : Controller
8
{
9
10
public ActionResult Index(string ImageShape)
11
{
12
var options = new List<string>();
13
options.Add("img-rounded");
14
options.Add("img-circle");
15
options.Add("img-thumbnail");
16
17
ViewBag.ImageShapesList = new SelectList(options);
18
19
if (String.IsNullOrEmpty(ImageShape))
20
{
21
ImageShape = null;
22
}
23
ViewBag.ImageShape = ImageShape;
24
25
return View();
26
}
27
}
28
}