my index.cshtml view
@model MvcApplication91.vikrant
@{
ViewBag.Title = "Index";
}
Index
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script type ="text/javascript">
$("#Create").click( function()
{
var url = "/Home/Index";
var name = $("#name").val();
var address = $("#address").val();
$.post(url, {name: Name, address: Address}, function(data)
{
$("#msg").html(data);
})
})
</script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
@using (Html.BeginForm()) {
@Html.ValidationSummary(true)
vikrant
@Html.LabelFor(model => model.name)
@Html.EditorFor(model => model.name)
@Html.ValidationMessageFor(model => model.name)
@Html.LabelFor(model => model.address)
@Html.EditorFor(model => model.address)
@Html.ValidationMessageFor(model => model.address)
<input type="submit" value="Create" />
}
@Html.ActionLink("Back to List", "Index")
controller
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 MvcApplication91.Controllers
{
public class HomeController : Controller
{
//
// GET: /Home/
[HttpPost]
public ActionResult Index( FormCollection formcollection)
{
vikrant bb = new vikrant();
bb.name = formcollection["name"];
bb.address = formcollection["address"];
hospitalEntities nn = new hospitalEntities();
nn.addemp(bb);
return RedirectToAction("Index");
}
[HttpGet]
public ActionResult Index()
{
return View();
}
}
}
guys kindly help me i want to print message inside span