Вы находитесь на странице: 1из 5

@{

ViewBag.Title = "View1";
}

<h2>View1</h2>
<p>@ViewBag.commonMsg</p>
<p> @ViewData["commonMsg"]</p>
@Html.Partial("PartialView");

public class testController : Controller


{
//
// GET: /test/
public ActionResult Index()
{
ViewBag.commonMsg = "This Is A Msg";
return View();
}
}
}

<h2>Index</h2>

@{
var products = new string[] { "Laptop", "Desktop", "KeyBoards" };

<html>
<head>
<title>
TEST VIEW
</title>
</head>
<body>
<ul>
@foreach (var str in products)
{
<li> The Product is : @str . </li>
}
</ul>
</body>
</html>
23/02/2019
@{
var msg = "hi";
var num = 13;
int num2 = 5;
string t = "string";
DateTime dt = DateTime.Today;
}

<section>
<p> @msg, and @num</p>
<p> Email adress is : misid311@@gmial.com</p>
<p> @num2, @t, @dt</p>
</section>
@{
var b = 0;
while(b<7)
{
b += 1;
<p> Text @b</p>
}

@{
int i = 1;
for (i=1; i<5; i++)
{
<p> 1 is : @i</p>
}
}
@{ var marks = 50; }

@if (marks > 80)


{
<p> PASS </p>
}
else
{
<p> FAIL</p>
}

@* Switch Case*@
@{
var day = DateTime.Now.DayOfWeek.ToString();
msg = "";

@switch (day)
{
case "Monday":
msg = "First day of week, Monday";
break;

case "Saturday":
msg = " Last day of week, Friday";
break;

default:
msg = "Today is :" + day;
break;
}
<p> @msg </p>
02/03/2019

public class TestController : Controller


{
//
// GET: /Test/
public ActionResult Index()
{
return View();
}
public ActionResult About()
{
return View();
}
}

@{
ViewBag.Title = "View1";
}

<h2>View1</h2>

@{Html.BeginForm("Index","Test");}

@Html.Label("Name: ")
@Html.TextBox("tb_name")

<br /><br />


@Html.Label("Adress: ")
@Html.TextArea("tb_adress")

<br /><br />


@Html.Label("Password")
@Html.Password("Password")
<br /><br />
@Html.Label("Remember Me")
@Html.CheckBox("cb_remember Me")

@Html.Label("City: ")
@Html.DropDownList("ddl_City", new SelectList(new []{"Karachi",
"Lahore"}),"Choose")
<br /><br />

@Html.Label("Gender:")
Male @Html.RadioButton("Gender","Male", true)
Female @Html.RadioButton("Gender","Female")

<input type="submit" />

@{Html.EndForm();}
<br/><br/>

<a href="https://www.google.com/" target="_blank"> Click hrer this is


Anchor</a>
<br /><br />
@Html.ActionLink("Click here", "About", "Test")

<br /><br />

<a href="@Url.Action("About", "Test")"> Click here this is Anchor</a>

Вам также может понравиться