Reputation: 324
Hi i am making my project in MVC, i which i want to add the control from the drop-down selection on right side div, (the black rectangle part in the image).
Now i have two requirements
i am getting the html with following button click function
$('#SaveCone').click(function () {
var a = $('#NewData').html();
console.log(a);
});
tell me please if you want another details, thanks for your kind help
Upvotes: 1
Views: 830
Reputation: 1500
this is nice question
If you want to store your html into the database, simply use ajax ,
$('#urbutton).click(function () {
var a = $('#yourForm).html();
$.ajax({
type: 'POST',
url: '/UrController/Uraction',
data:
$('#MyForm').serialize() + "&par2=" + a,
success: function (data) {
// ` alert(data);
}
});
});
your controller looks like this
public ActionResult Create(Table table, string par2)
{
using (urcontext cntxt = new urcontext ())
{
if (ModelState.IsValid)
{
table.data = par2;
cntxt.SaveChanges();
}... so on
this will store your data into database
How to render the Html from database to the view
simply use
<div id="container">
@HTML.Raw(model.data)
< /div>
Hope this will help you man
Upvotes: 1