Я работаю над проектом, в котором пользователь может загружать комментарии, и я хочу отобразить все загруженные данные на той же странице, куда пользователь загрузил данные. Как я могу это сделать, пожалуйста, помогите мне с этим, что является хорошим способом сделать этоЯ пытался сделать следующее, но не смог получить ожидаемый результат
public ActionResult Gandhiji(int? id)
{
ViewBag.Message = "150 Years Of Gandhiji";
IEnumerable<UserComments> obj = db.UserComments;
if(id!=null)
{
obj = obj.Where(p => p.Id == id);
}
return View("Gandhiji",obj);
}
@model BigFoot.UsercommentsImage
@using (Html.BeginForm("Gandhiji", "Home", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
@Html.AntiForgeryToken()
<h4 style="margin-left:30px;">User Comments</h4>
<div class="form-horizontal">
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(model => model.Name, "Name", htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Name, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Name, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.PhoneNumber, "Phone Number", htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.PhoneNumber, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.PhoneNumber, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Email, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Email, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Email, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Comments, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.TextAreaFor(model => model.Comments, new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.Comments, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<label class="control-label col-md-2">Picture:</label>
<div class="col-md-10">
<input class="form-control" type="file" id="UploadedFile" name="UploadedFile" />
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Submit" class="btn btn-default" />
</div>
</div>
</div>
}
<img src="@Item.Path"/>
</div>
</div>
public class UsercommentsImage
{
public int Id { get; set; }
[Required]
public string Name { get; set; }
[Required]
[Phone]
public string PhoneNumber { get; set; }
[Required]
[EmailAddress]
public string Email { get; set; }
[Required]
public string Comments { get; set; }
public string Path { get; set; }
public HttpPostedFileBase UploadedFile { get; set; }
}