@model MvcApplication90.vikrant @{ ViewBag.Title = "Index"; Layout = "~/Views/Shared/_Layout.cshtml"; } <html> <head> <script src="@Url.Content("~/Scripts/jquery-1.7.1.min.js")" type="text/javascript"></script> <script type ="text/javascript"> $("#submit").click(function () { var url = "/Home/Index"; var name = $("#name").val() var address = $("#address").val() $.post(url, { Name: name, Address: address }, function (data) { $("#result").html(data) }) }) </script> </head> <body> <h2>Index</h2> @section Feature { @using (Html.BeginForm( "Home","Index", FormMethod.Post, new { id = "frm"})) { <table> <tr> <td> @Html.LabelFor(model => model.name) @Html.TextBoxFor( Model => Model.name) </td> </tr> <tr> <td> @Html.LabelFor( model => model.address) @Html.TextBoxFor( model => model.address) </td> </tr> <tr> <td> <input type ="submit" id ="dd", value ="submit" /> </td> </tr> </table> <div id="result" style="color:gray;"></div> } </body> </html>
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>@ViewBag.Title</title> <link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" /> <script src="@Url.Content("~/Scripts/jquery-1.7.1.min.js")" type="text/javascript"></script> <script src="@Url.Content("~/Scripts/modernizr-2.5.3.js")" type="text/javascript"></script> </head> <body> @RenderBody() @RenderSection("Feature") </body> </html>
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using System.Data; using System.Data.SqlClient; using System.Configuration; namespace MvcApplication90.Controllers { public class HomeController : Controller { [HttpGet] [ActionName("Index")] public ActionResult Index() { return View(); } [HttpPost] [ActionName("Index")] public ActionResult Index( FormCollection formcollection) { vikrant cc = new vikrant(); cc.name = formcollection["name"]; cc.address = formcollection["address"]; hospitalEntities tt = new hospitalEntities(); tt.addemp(cc); return "thank u" + Name + "SUBMITTED"; } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)