0% found this document useful (0 votes)
3 views2 pages

DynamicRazorView 150525

The document contains an ASP.NET MVC view (Index.cshtml) that defines a form for user input, including fields for username, password, address, hobbies, gender, and country selection. It utilizes various HTML helpers to create text boxes, checkboxes, radio buttons, and a dropdown list. Additionally, there is a HomeController that returns the Index view when accessed.

Uploaded by

joy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

DynamicRazorView 150525

The document contains an ASP.NET MVC view (Index.cshtml) that defines a form for user input, including fields for username, password, address, hobbies, gender, and country selection. It utilizes various HTML helpers to create text boxes, checkboxes, radio buttons, and a dropdown list. Additionally, there is a HomeController that returns the Index view when accessed.

Uploaded by

joy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Code in Index.

cshtml
-----------------------------------------------------------------------------------
-----------------
@{
Layout = null;
}

<!DOCTYPE html>

<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
</head>

@{ var Countrylist = new List<string> { "India", "Turkey", "Pakisthan",


"Bangladesh" }; } ..declaring the countrylist

<body>
@using (Html.BeginForm("Index", "Home", FormMethod.Post))
{

<div>
UserName: @Html.TextBox("TextBox1")<br /><br />..defining the text
box
Password: @Html.Password("TextBox2")<br /><br />--defining the
password field
Address: @Html.TextArea("TextBox3")<br /><br />--defining the text
area
</div>
<div>
Hobbies:
@Html.CheckBox("Hobbies", false)Cricket ...defining a checkbox
@Html.CheckBox("Hobbies", true)Chess
@Html.CheckBox("Hobbies", false)Hockey
</div><br /><br />
<div>
Gender:
@Html.RadioButton("Gender", false)Male---defining a radio button
@Html.RadioButton("Gender", false)Female
</div><br /><br />
<div>
Country:
@Html.DropDownList("ddlCountry", new SelectList(Countrylist),
"Select");--defining the dropdown
</div> <br /><br />
<div>
<input type="Submit" value="Save">
</div>
}
</body>
</html>

-------------Homecontroller---------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MVCProject01.Models;

namespace MVCProject01.Controllers
{

public class HomeController : Controller


{
// GET: Home
public ViewResult Index()
{
return View();
}

}
}

You might also like