C# 更新列表内容
我有一个列表,可以由用户编辑和显示更新的信息,我试图做回发,但我无法实现它。 有人能指导我实现它吗C# 更新列表内容,c#,javascript,asp.net,asp.net-mvc-4,C#,Javascript,Asp.net,Asp.net Mvc 4,我有一个列表,可以由用户编辑和显示更新的信息,我试图做回发,但我无法实现它。 有人能指导我实现它吗 我的编辑工作得很好,但当我单击“完成”时,它会显示新编辑的数据。谢谢你的帮助。我已经试着按照你的要求去做了,请看下面的代码 控制器:- public ActionResult Movie() { MyModel model = new MyModel(); return View(model); } [HttpP
我的编辑工作得很好,但当我单击“完成”时,它会显示新编辑的数据。谢谢你的帮助。我已经试着按照你的要求去做了,请看下面的代码 控制器:-
public ActionResult Movie()
{
MyModel model = new MyModel();
return View(model);
}
[HttpPost]
public ActionResult Movie(Current mod)
{
MyModel car = new MyModel();
////if (mod.FormAction.Equals("Done"))
////{
mod.Headers = mod.Headers;
mod.Ids = mod.Ids;
mod.Contents = mod.Contents;
car.Currents.Add(mod);
UpdateModel(car);
return View(car);
///}
////return View();
}
脚本:-
$(document).ready(function () {
$('#edit1').click(function () {
document.getElementById("newpanel1").contentEditable = "true";
document.getElementById("collapseTwo").contentEditable = "true";
$('#newpanel1').attr('style', 'border:2px solid;');
$('#collapseTwo').attr('style', 'border:2px solid;');
$('#edit1').attr('style', 'display:none;');
$('#done1').attr('style', 'display:inline:block;');
});
$('#done').click(function () {
document.getElementById("newpanel1").contentEditable = "false";
document.getElementById("collapseTwo").contentEditable = "false";
//$("#myContent").val($("#panel1").html());
$('#newpanel1').attr('style', 'border:none;');
$('#collapseTwo').attr('style', 'border:none;');
$('#edit1').attr('style', 'display:block;');
$('#done1').attr('style', 'display:none;');
var header = $("#span").html();
var cars = { Ids: 3, Headers: header, Contents: "sdfsdf" };
alert(cars.Headers);
$.ajax({
url: "/Home/Movie",
type: "POST",
data: JSON.stringify(cars),
dataType: 'json',
contentType: "application/json; charset=utf-8",
success: function(lol) {
alert(lol);
}
});
});
$('#delete').click(function () {
$('#newpanel1').text('');
})
});
视图:-
<div class="panel panel-default" id="panel2">
<div class="panel-heading-new">
<h4 class="panel-title" id="newpanel1">
<a data-toggle="collapse" data-target="#collapseTwo" href="#collapseTwo">
Title
</a>
</h4>
<a href='#' id="edit1" class="edit-link">Edit</a>
<input type="button" value =" done" id ="done"/>
<a href='#' class="delete-link" id="delete1">Hide</a>
</div>
<div id="collapseTwo" class="panel-collapse collapse in">
<div class="panel-body">
<p class="lead justified">
Qualifications and Skills:
</p>
<ul class="fa-ul">
<li><i class="fa-li fa fa-hand-o-right pad-icon"></i><span class="lead justified" id="span">Hello</span></li>
</ul>
<br />
<p class="lead justified">Location: Pune</p>
</div>
</div>
</div>
资格和技能:
- 你好
地点:普纳
小提琴:-
您正在使用javascript进行编辑??如何说您的编辑正在使用jquery进行编辑。因为我可以在div.Js fiddle中编辑东西以进行编辑,所以当单击“完成”时,您正在将控制重定向到“主”控制器的“carler”操作。您在服务器端得到了什么东西?为什么您的fiddle不工作?更新的fiddle谢谢,将尝试一下并返回给您。:)是的,好的,当然@RS26:)谢谢您的帮助,但仍然没有运气。刷新时仍不显示已编辑的内容。我想我将不得不使用HTTPPOst代码,因为问题就在那里。是的,没错。但我读到有一种方法可以在会话中存储临时数据,并在回发时查看。我知道列表数据不会改变,我只是想用某种方式显示编辑过的数据。对不起,我删除了我的评论,因为它没有用@RS26。明白了吗