@{
ViewBag.Title = "Home Page";
}
<h2>@ViewBag.Message</h2>
<p>
To learn more about ASP.NET MVC visit <a href="http://asp.net/mvc" title="ASP.NET MVC Website">http://asp.net/mvc</a>.
</p>
@using (Html.BeginForm("Checkbox", "Home", FormMethod.Post))
{
<table>
<tr><td>Sr No</td><td>Checkbox</td><td>Value</td></tr>
@{
for (int i = 1; i < 10; i++)
{
<tr><td>@i</td><td><input type="checkbox" name="che" value="@i" id="checkbo"/></td><td>@i</td></tr>
}
}
</table>
<p><input type="submit" value="Submit" /></p>
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace Mvccheckboxsantosh.Controllers
{
public class HomeController : Controller
{
public ActionResult Index()
{
ViewBag.Message = "Welcome to ASP.NET MVC!";
return View();
}
public ActionResult About()
{
return View();
}
[HttpPost]
public ActionResult Checkbox(FormCollection frm)
{
string[] che = frm.GetValues("che");
return View();
}
}
}
-----------------------------------------------------------
No comments:
Post a Comment