morry329#
morry329#
CC#
Created by morry329# on 2/13/2025 in #help
Id points to always null
Could you kindly point out which type in which input exactly you mean ? Please just point out which line out of the following cshtml
<div id="EditDashboardNow" method="post" name="editSubmitId">
<form method="post" asp-route="Form" id="editSubmitId" name="editSubmitId">
@using (Html.BeginForm("EditListingJpost", "Home", FormMethod.Post, new { @class = "ListingProjectsDTO", @id = "MyId", enctype = "multipart/form-data" }))
{
<div class="listing form-horizontal">
<div><img class="listingPhoto" src="~/imgSearchHome/IMG_20220102_161928.jpg"/></div>
<div class="content">
<input type="hidden" id="EditIdButHidden" name="EditIdButHidden"/>
<input type="hidden" id="editPropertyName" name="editPropertyName"/>
<p>Property Name:
<div class="form-group">
<input class="form-control" type="text" id="editPropertyName" name="editSubmitId"/>
<p>try this form also</p>
<input class="form-control" type="text" name="editSubmitId"/>
</div>
<picture>I am the EditDashboard now</picture>
</p>

<div>
<button type="button" id="btnSaveEdit" value="Save" onclick="EditListingJpost(@listingMd.Id)">Save</button>

<div id="EditDashboardNow" method="post" name="editSubmitId">
<form method="post" asp-route="Form" id="editSubmitId" name="editSubmitId">
@using (Html.BeginForm("EditListingJpost", "Home", FormMethod.Post, new { @class = "ListingProjectsDTO", @id = "MyId", enctype = "multipart/form-data" }))
{
<div class="listing form-horizontal">
<div><img class="listingPhoto" src="~/imgSearchHome/IMG_20220102_161928.jpg"/></div>
<div class="content">
<input type="hidden" id="EditIdButHidden" name="EditIdButHidden"/>
<input type="hidden" id="editPropertyName" name="editPropertyName"/>
<p>Property Name:
<div class="form-group">
<input class="form-control" type="text" id="editPropertyName" name="editSubmitId"/>
<p>try this form also</p>
<input class="form-control" type="text" name="editSubmitId"/>
</div>
<picture>I am the EditDashboard now</picture>
</p>

<div>
<button type="button" id="btnSaveEdit" value="Save" onclick="EditListingJpost(@listingMd.Id)">Save</button>

`
7 replies
CC#
Created by morry329# on 2/13/2025 in #help
Id points to always null
Could you kindly point me what went wrong here .. I mean I tried to map the controller to the cshtml but the id is still null at my controller My controller https://pastebin.com/cSzKufsU My cshtml https://pastebin.com/rwqSwMV2 <--- I even created a form tag to mark the form field with the same Id in controller. Still none of these helped
7 replies
CC#
Created by morry329# on 2/8/2025 in #help
The edit method does not edit the pre-existing data but it creates a new data entry with NULL
With FromBody I always get the server responded with a status of 415 (Unsupported Media Type) That's why I went with FromForm to get rid of this error
26 replies
CC#
Created by morry329# on 2/8/2025 in #help
The edit method does not edit the pre-existing data but it creates a new data entry with NULL
Still, the edited input will not get saved and the DB gets the NULL entry just like before
26 replies
CC#
Created by morry329# on 2/8/2025 in #help
The edit method does not edit the pre-existing data but it creates a new data entry with NULL
So my rider does not let me set any breakpoint in code (the point will get marked by 🚫 ), I did something like this as debug [HttpGet] public JsonResult EditListingJ(int? Id) //For getting details of the selected User { try { ListingProjectsDTO StartEditListing = _context.ListingDTO_DBTable.Find(Id); Console.WriteLine("GET success"); return Json(StartEditListing); } catch (Exception e) { return null; } } [HttpPost] public JsonResult EditListingJ([FromForm]ListingProjectsDTO _completeEditNowListingProjectsDto) { try { _context.ListingDTO_DBTable.Update(_completeEditNowListingProjectsDto); _context.SaveChanges(); Console.WriteLine("POST success"); return Json(_completeEditNowListingProjectsDto); } catch (Exception ex) { return Json(ex.Message); } } This code returns both of Console.WriteLine("GET success") and Console.WriteLine("POST success");
26 replies
CC#
Created by morry329# on 2/8/2025 in #help
The edit method does not edit the pre-existing data but it creates a new data entry with NULL
so the problem still persists unfortunately. it definitely lies in the backend like db
26 replies
CC#
Created by morry329# on 2/8/2025 in #help
The edit method does not edit the pre-existing data but it creates a new data entry with NULL
So if that .Update() method is custom-made the DbSet could be updated, did I understand that correctly?
26 replies
CC#
Created by morry329# on 2/8/2025 in #help
The edit method does not edit the pre-existing data but it creates a new data entry with NULL
No description
26 replies
CC#
Created by morry329# on 2/8/2025 in #help
The edit method does not edit the pre-existing data but it creates a new data entry with NULL
A stupid question maybe, but how could ListingDTO_DBTable be sent as it is? (Also without creating a nested object=)?
26 replies
CC#
Created by morry329# on 2/8/2025 in #help
The edit method does not edit the pre-existing data but it creates a new data entry with NULL
Ahhhh you got an amazing set of eyes .. Thank you so much for pointing that out, could not notice it myself
26 replies
CC#
Created by morry329# on 2/8/2025 in #help
The edit method does not edit the pre-existing data but it creates a new data entry with NULL
So my entity is in the added state as it has no primary key set (henceforth my app adds a new entry instead of editing the pre-existing one). Did I understand the doc correctly?
26 replies
CC#
Created by morry329# on 1/30/2025 in #help
✅ NullPointException in the Update/Post method, but not in the Get Method
r/closed
46 replies
CC#
Created by morry329# on 1/30/2025 in #help
✅ NullPointException in the Update/Post method, but not in the Get Method
r/solved
46 replies
CC#
Created by morry329# on 1/30/2025 in #help
✅ NullPointException in the Update/Post method, but not in the Get Method
alright
46 replies
CC#
Created by morry329# on 1/30/2025 in #help
✅ NullPointException in the Update/Post method, but not in the Get Method
ok I see. I would like to work on one thing at the time which is that null
46 replies
CC#
Created by morry329# on 1/30/2025 in #help
✅ NullPointException in the Update/Post method, but not in the Get Method
One more question, if it should never be a class instance, what should it be instead?
46 replies
CC#
Created by morry329# on 1/30/2025 in #help
✅ NullPointException in the Update/Post method, but not in the Get Method
Some weeks ago, my code needed to check if the HTTP request would hit the controller action while bypassing the frontend. So I forgot to remove that 'remnant' from this experiement
46 replies
CC#
Created by morry329# on 1/30/2025 in #help
✅ NullPointException in the Update/Post method, but not in the Get Method
Ok I will fix that part later once the Edit is fixed.
46 replies
CC#
Created by morry329# on 1/30/2025 in #help
✅ NullPointException in the Update/Post method, but not in the Get Method
DeleteJ is working as I wanted (aka it deletes the entry I don't need anymore), so I might fix it once the edit is fixed
46 replies
CC#
Created by morry329# on 1/30/2025 in #help
✅ NullPointException in the Update/Post method, but not in the Get Method
ListingProjectsDTO public class ListingProjectsDTO { [System.ComponentModel.DataAnnotations.Key] public int? Id { get; set; } // Primary key for DTO public string? ListingName { get; set; } // Mapped from ListingName in ListingProjects } getListingProjectsDto is not a class but a part of interface public interface IListingProjectsDtoRepository { ListingProjectsDTO getListingProjectsDto(int? Id); IEnumerable<ListingProjectsDTO> GetAllEmployee(); } So it explains pretty much why it gives me the nullpointException then
46 replies