Hello.cshtml
@{
var strName = "";
if(IsPost)
{
strName = "Hello welcome to Razor";
}
}
<form method="post">
<p>
@strName
</p>
<input type="submit" value="Submit" id="submit1"/>
</form>
TextBoxVal.cshtml
@{
var strName = "";
if(IsPost)
{
strName = "Hello " + Request["txtName"];
}
}
<form method="post">
<p>
@strName
</p>
Name
<input name="txtName" type="text" />
<br />
<br />
<input type="submit" value="Submit" id="submit1"/>
</form>
sum.cshtml
@{
var sum = 0;
if(IsPost)
{
sum = Request["txtValue1"].AsInt() + Request["txtValue2"].AsInt();
}
}
<form method ="post">
<p>
@sum
</p>
Value 1<input name= "txtValue1" type="text" />
<br />
Value 2<input name= "txtValue2" type="text" />
<br />
<input id="Submit1" type="submit" value="submit" />
</form>
Session.cshtml
@{
Session["name"] = "dear";
}
<form method="post">
<a href = "@Href("Welcome")">Welcome</a>
</form>
Welcome.cshtml
@{
var strName = "Hello " + Session["Name"];
}
<form>
<p>
@strName
</p>
</form>
@{
var strName = "";
if(IsPost)
{
strName = "Hello welcome to Razor";
}
}
<form method="post">
<p>
@strName
</p>
<input type="submit" value="Submit" id="submit1"/>
</form>
TextBoxVal.cshtml
@{
var strName = "";
if(IsPost)
{
strName = "Hello " + Request["txtName"];
}
}
<form method="post">
<p>
@strName
</p>
Name
<input name="txtName" type="text" />
<br />
<br />
<input type="submit" value="Submit" id="submit1"/>
</form>
sum.cshtml
@{
var sum = 0;
if(IsPost)
{
sum = Request["txtValue1"].AsInt() + Request["txtValue2"].AsInt();
}
}
<form method ="post">
<p>
@sum
</p>
Value 1<input name= "txtValue1" type="text" />
<br />
Value 2<input name= "txtValue2" type="text" />
<br />
<input id="Submit1" type="submit" value="submit" />
</form>
Session.cshtml
@{
Session["name"] = "dear";
}
<form method="post">
<a href = "@Href("Welcome")">Welcome</a>
</form>
Welcome.cshtml
@{
var strName = "Hello " + Session["Name"];
}
<form>
<p>
@strName
</p>
</form>