如何解决执行处理程序“System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerAsyncWrapper”的子请求时出错在其他视图中渲染视图时发生
当我尝试将一个视图渲染到另一个视图中时,发生了此错误。当我提交按钮时出现异常,但在其他视图'提交按钮上出错 控制器 公共 PartialViewResult Create1() { var 项目 = db.RegisteredStudents.ToList(); SelectList list = new SelectList(projects,"Finalyear_Id","Prject_title"); ViewBag.listss = list;
ViewBag.Project_title = new SelectList(db.RegisteredStudents,"Prject_title");
return PartialView("_Create1");
}
[HttpPost]
[ValidateAntiForgeryToken]
public PartialViewResult Create1([Bind(Include = "fyp_Id,Project_title,Evaluation_Type,Total_Marks,Obtain_Marks,Defence_average,Defence_SD,Defence_Minimum,Defence_Maximum,Fyp1_mid_average,Fyp1_mid_SD,Fyp1_mid_Minimum,Fyp1_mid_Maximum,Fyp1_final_average,Fyp1_final_SD,Fyp1_final_Minimum,Fyp1_final_Maximum")] fyp1Evaluations fyp1Evaluations)
{
var projects = db.RegisteredStudents.ToList();
SelectList list = new SelectList(projects,"Prject_title");
ViewBag.lissts = list;
ViewBag.Project_title = new SelectList(db.RegisteredStudents,"Prject_title");
if (ModelState.IsValid)
{
var search = db.fyp1Evaluations.Where(a => a.Project_title == fyp1Evaluations.Project_title && a.Evaluation_Type == fyp1Evaluations.Evaluation_Type).FirstOrDefault();
if (search != null)
{
TempData["msg1"] = "<script>alert('Already Added');</script>";
return PartialView("_Create1");
}
if (fyp1Evaluations.Obtain_Marks > fyp1Evaluations.Total_Marks)
{
TempData["msg"] = "<script>alert('Obtained Marks Cannot be greater than total marks');</script>";
return PartialView("_Create1");
}
try
{
db.fyp1Evaluations.Add(fyp1Evaluations);
db.SaveChanges();
return PartialView("_Create1");
}
catch(Exception e)
{
}
}
ViewBag.Project_title = new SelectList(db.RegisteredStudents,"Prject_title",fyp1Evaluations.Project_title);
//fyp1Evaluations.Defence_average = (int?)db.fyp1Evaluations.Where(d => d.Evaluation_Type == "Defence Evaluation").Average(d => d.Obtain_Marks);
return PartialView(fyp1Evaluations);
}
**View 1**
这是我想在其中渲染另一个视图的视图,但是当我尝试提交此视图的按钮时出现异常。
@模型
Infocus_Digitilization_of_an_Fyp_Process.Areas.Coordinator.Models.RegisteredStudent
@{
ViewBag.Title = "FYP 1 Evaluations";
Layout = "~/Areas/Coordinator/Views/Shared/_Layout.cshtml";
}
@ViewBag.Message
<head>
<style>
h1 {
text-align: center;
}
body {
background-image: url('../../../../Images/loginbackground.jpg');
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
</style>
</head>
<body>
@{Html.RenderAction("Create1","StudentEvaluationsFyp1"); }
@using (Html.BeginForm("calculateMarks","StudentEvaluationsFyp1",FormMethod.Post))
{
@Html.AntiForgeryToken()
<input type="text" id="txt" readonly="readonly" />
@Html.DropDownList("Prject_title",ViewBag.lissts as SelectList,"Select",new { @onChange = "selectedtext(this)" })
<button type="submit" value="submit">Submit</button>
}
<div>
<table class="table">
<tr>
<th>
Total Marks
</th>
<th>
Obtained Marks
</th>
</tr>
<tr>
<td>
100
</td>
<th>
@ViewBag.TotalStudents
</th>
</tr>
</table>
</div>
</body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script>
function selectedtext(ddlitem) {
var selvalue = ddlitem.value;
var seltext = ddlitem.options[ddlitem.selectedindex].innerHTML;
$('#txt').val(seltext);
}
</script>
**View 2**This is the view in which I want to Render another View
@model Infocus_Digitilization_of_an_Fyp_Process.Areas.Coordinator.Models.fyp1Evaluations
<h2>Create</h2>
@Html.Raw(TempData["msg1"])
@Html.Raw(TempData["msg"])
<head>
<style>
span.field-validation-error {
color: red;
}
h1 {
text-align: center;
}
body {
background-image: url('../../../../Images/loginbackground.jpg');
background-position: center;
background-repeat: no-repeat;
background-size: cover
}
</style>
</head>
<body>
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<hr />
@Html.ValidationSummary(true,"",new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(model => model.Project_title,"Project title",htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.DropDownList("Project_title",null,htmlAttributes: new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.Project_title,new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Evaluation_Type,"Evaluation Type",htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.DropDownList("Evaluation_Type",new List<SelectListItem>
{
new SelectListItem{Text="Defence Evaluation",Value="Defence Evaluation",Selected=true},new SelectListItem{Text="Fyp1-Mid Evaluation",Value="Fyp1-Mid Evaluation"},new SelectListItem{Text="Fyp1-Final Evaluation",Value="Fyp1-Final Evaluation"},},"Select Evaluation Type",new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.Evaluation_Type,new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Total_Marks,"Total Marks",htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Total_Marks,new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Total_Marks,new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Obtain_Marks,"Obtain Marks",htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Obtain_Marks,new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Obtain_Marks,new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Create" class="btn btn-success" />
<a class="popup btn btn-secondary" href="Index">Back to List</a>
</div>
</div>
</div>
}
</body>
<div>
@*@Html.ActionLink("Back to List","Index")*@
</div>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。