© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
50 replies
EnderLeWolf

✅ Nested views failing

Hello! so, I've got a small issue.
I have this view called Edit which has the following button:

<div class="form-group">
<input type="submit" id="SaveEdit" value="Save" class="btn btn-primary" />
</div>
<div class="form-group">
<input type="submit" id="SaveEdit" value="Save" class="btn btn-primary" />
</div>

I am trying to get it so that when this button is clicked, it takes the user back to having the details view opened in this part of the dashboard view (note the page with the submit button is currently opened in there)

<div class="dash-content col py-3" id="contentArea">

</div>
<div class="dash-content col py-3" id="contentArea">

</div>


this is my current js

$('#SaveEdit').click(function() {
preventDefault(); // Prevent the default action of the link
var submissionId = $(this).attr('value'); // Get the ID of the submission
$.ajax({
url: '/Submission/Edit/' + submissionId,
type: 'GET',
success: function(result) {
$('#contentArea').html(result);
}
});
});
$('#SaveEdit').click(function() {
preventDefault(); // Prevent the default action of the link
var submissionId = $(this).attr('value'); // Get the ID of the submission
$.ajax({
url: '/Submission/Edit/' + submissionId,
type: 'GET',
success: function(result) {
$('#contentArea').html(result);
}
});
});


here's the end point it hits:

[HttpPost]
[ValidateAntiForgeryToken]
[Authorize(Roles = "Admin")]
public async Task<IActionResult> Edit(int id, Event @event)
{
if (id != @event.EventId)
{
return NotFound();
}
ModelState.Remove("");
if (ModelState.IsValid)
{
try
{
var @submission = await _context.Event.FirstOrDefaultAsync(m => m.EventId == id);
@submission.EventEditedDate = @event.EventEditedDate;
_context.Update(@submission);
await _context.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
{
if (!EventExists(@event.EventId))
{
return NotFound();
}
else
{
throw;
}
}
return RedirectToAction("Details", new { id = id });
}
return RedirectToAction("Details", new { id = id });
}
[HttpPost]
[ValidateAntiForgeryToken]
[Authorize(Roles = "Admin")]
public async Task<IActionResult> Edit(int id, Event @event)
{
if (id != @event.EventId)
{
return NotFound();
}
ModelState.Remove("");
if (ModelState.IsValid)
{
try
{
var @submission = await _context.Event.FirstOrDefaultAsync(m => m.EventId == id);
@submission.EventEditedDate = @event.EventEditedDate;
_context.Update(@submission);
await _context.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
{
if (!EventExists(@event.EventId))
{
return NotFound();
}
else
{
throw;
}
}
return RedirectToAction("Details", new { id = id });
}
return RedirectToAction("Details", new { id = id });
}


and this is the Details end point:

[Authorize(Roles = "Admin")]
public async Task<IActionResult> Edit(int? id)
{
if (id == null || _context.Event == null)
{
return NotFound();
}
var @event = await _context.Event.FindAsync(id);
if (@event == null)
{
return NotFound();
}
return View(@event);
}
[Authorize(Roles = "Admin")]
public async Task<IActionResult> Edit(int? id)
{
if (id == null || _context.Event == null)
{
return NotFound();
}
var @event = await _context.Event.FindAsync(id);
if (@event == null)
{
return NotFound();
}
return View(@event);
}


I have some almost identical code that works fine, but this one seems to just open the view as a whole view instead of nested inside the first
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements
Next page

Similar Threads

best approach to handle a nested Scrolling views
C#CC# / help
14mo ago
Views omg
C#CC# / help
11mo ago
DI and Views
C#CC# / help
13mo ago
❔ WPF Change Views
C#CC# / help
3y ago