return RedirectToAction("List_News","Admins"); クロムで動作しません。すべてのブラウザで問題ありません。彼らはフォームをクリアしますが、クロムはデータを再送信します! 助けてください、誰かがこの問題の解決策を知っているかもしれません!
意見
<div class="list_news" >
<script type="text/javascript">
$(document).ready(function () {
$("input").keypress(function (e) {
if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {
return false;
}
});
});
</script>
<ul>
@foreach (var News in Model.Anew)
{
if (News.hide != 0)
{
<li>
@using (Html.BeginForm())
{
<span style="float: left" class="span_edit">Позиція:</span>
@Html.TextBoxFor(m => m.Required.Thisposition, new { Value = News.position, @class = "edit_position", maxlength = "4" })
<span style="float: left; margin-left: 10px;" class="span_edit">Видалити:</span>
@Html.CheckBoxFor(x => x.Required.hide, new { @class = "span_edit", style = "float: left; margin-left:10px; margin-top:8px;" })
@Html.HiddenFor(m => m.Required.list_id_news, new { Value = News.Id })
@Html.HiddenFor(m => m.Required.OldPosition, new { Value = News.position })
<input type="submit" value="Зберегти" style="float: left; margin: 0; margin-left: 10px;" class="save"/>
}
@Html.ActionLink(News.name_news, "News", new { news_id = News.Id })
<span style=" margin-left: 38px; font-weight: normal; display: inline-block; width: auto; height: auto; color: red" class="span_edit">@TempData[News.Id.ToString()] </span>
</li>
}
}
</ul>
</div>
コントローラ
public ActionResult List_News()
{
ListNews tr = new ListNews();
tr.Anew = ot.GetNewsAll();
tr.Categorynew = ot.Allcategory();
return View(tr);
}
[HttpPost]
public ActionResult List_News(ListNews model)
{
if (Convert.ToInt64(model.Required.Thisposition) >= ot.NewsMin() && Convert.ToInt64(model.Required.Thisposition) <= ot.NewsMax())
{
if (model.Required.hide)
{
ot.UpdateNews(model.Required.list_id_news, 0);
ot.ReestablishPosition(model.Required.list_id_news, model.Required.OldPosition);
}
if (!model.Required.hide && model.Required.OldPosition != Convert.ToInt64(model.Required.Thisposition) &&
model.Required.OldPosition < Convert.ToInt64(model.Required.Thisposition))
{
ot.ChangePositionDown(model.Required.list_id_news, Convert.ToInt64(model.Required.Thisposition),
model.Required.OldPosition);
}
if (!model.Required.hide && model.Required.OldPosition != Convert.ToInt64(model.Required.Thisposition) &&
model.Required.OldPosition > Convert.ToInt64(model.Required.Thisposition))
{
ot.ChangePositionUp(model.Required.list_id_news, Convert.ToInt64(model.Required.Thisposition),
model.Required.OldPosition);
}
}
else
{
TempData[model.Required.list_id_news.ToString()] = "Позиція повина бути в проміжку від " +
ot.NewsMin().ToString() + " до " +
ot.NewsMax().ToString()+"!";
}
ModelState.Clear();
return RedirectToAction("List_News","Admins");
}