Hello,
I'm working on a sample form to understand how to work with KendoUI, Asp.net MVC3 and MySql database.
I have created the form as a View on Create action of the controller but I cant seem to get the model to store the data inputed into the form.
I need to know how to link the Kendo control to my model.
Create.cshtml
@model MvcApplication_Movie.Models.movie_master
@{
ViewBag.Title = "Create";
}
<h2>Add New Movie</h2>
@using (Html.BeginForm())
{
@Html.ValidationSummary(true)
<fieldset>
<h3>Movie Name:</h3>
<input type="text" id="movie_name" class="k-textbox"/>
<br />
<h3>Release Date:</h3>
@(Html.Kendo().DatePicker()
.Name("datepicker")
.HtmlAttributes(new { style = "width:150px" })
)
<br />
<h3>Movie Poster:</h3>
@(Html.Kendo().Upload().Name("files"))
<br />
<input type="submit" id="submit" onclick="ins_mod()" value="Add Movie" class="k-button" />
</fieldset>
}
The controller method
[HttpPost]
public ActionResult Create(movie_master movie_record)
{
try
{
// Insert Movie logic here
using (var insert = new moviesEntities())
{
insert.movie_master.Add(movie_record);
insert.SaveChanges();
}
return RedirectToAction("Index");
}
catch
{
return View();
}
}
Please help me asap. Thank you
I'm working on a sample form to understand how to work with KendoUI, Asp.net MVC3 and MySql database.
I have created the form as a View on Create action of the controller but I cant seem to get the model to store the data inputed into the form.
I need to know how to link the Kendo control to my model.
Create.cshtml
@model MvcApplication_Movie.Models.movie_master
@{
ViewBag.Title = "Create";
}
<h2>Add New Movie</h2>
@using (Html.BeginForm())
{
@Html.ValidationSummary(true)
<fieldset>
<h3>Movie Name:</h3>
<input type="text" id="movie_name" class="k-textbox"/>
<br />
<h3>Release Date:</h3>
@(Html.Kendo().DatePicker()
.Name("datepicker")
.HtmlAttributes(new { style = "width:150px" })
)
<br />
<h3>Movie Poster:</h3>
@(Html.Kendo().Upload().Name("files"))
<br />
<input type="submit" id="submit" onclick="ins_mod()" value="Add Movie" class="k-button" />
</fieldset>
}
The controller method
[HttpPost]
public ActionResult Create(movie_master movie_record)
{
try
{
// Insert Movie logic here
using (var insert = new moviesEntities())
{
insert.movie_master.Add(movie_record);
insert.SaveChanges();
}
return RedirectToAction("Index");
}
catch
{
return View();
}
}
Please help me asap. Thank you