Click here to Skip to main content
15,891,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900