Categories
Development

html dropdownlist load first value

Controller ViewBag.Districts = new SelectList(repoBPASFM.Map<DistrictDTOList>(“GetDistrict”), “DistrictID”, “DistrictName”, null); HTML <div class=”col-lg-4″> <label> District </label> <span class=”text color-red”> * </span> @Html.DropDownList(“DistrictName”, ViewData[“Districts”] as SelectList, new { @class = “form-control”, @required = “required” }) </div> I have this code above working fine it shows all the data in the dropdown. But I am having a problem, I […]

Categories
Development

NullReferenceException: Object reference not set to an instance of an object when trying to create a cascading dropdown list in ASP.NET Core MVC [duplicate]

I am trying to create a view model that allows the user to create a new product by typing in the products new name and then select which parent category it belongs to, which then filters the sub category and the user selects the appropriate sub-category. I am currently just trying to have both a […]

Categories
Development

ASPCORE MVC ViewModel property Return Null On Post

inside viewModel class i have a public List<SelectListItem> Genres { get; set; } property, wich is comes from DB. But when form submit, This Property being null. This is the Get action [HttpGet] [Route(“PostAd”)] public async Task<IActionResult> PostAd() { var model = new PostAdViewModel(); var Genres = new List<SelectListItem>(); var dbGenres = _appDbContext.Genres.ToList(); var SelectListGroups […]

Categories
Development

Cascade dropdown list MVC 5 Razor

I am attempting to implement Drop Down Cascading in the C#.NET MVC5 project. I am unable to populate the list of intakes though I can see in the debugger the list of intakes is returning. Please help! Controller: public JsonResult GetIntakeList(int ProgramId) { _context.Configuration.ProxyCreationEnabled = false; var programs = _context .Programs .Include(a => a.Intakes) .Where(p […]

Categories
Development

wrong saving with one to many relationship .net mvc

I have one to many relationships between Appointments(Services_Id FK) and Services tables, When I Post new appointment it is supposed to insert Services_Id in appointment table but it creates a new record in Services table Controller: // GET public ActionResult Create() { AspNetUser aspNetUser = new AspNetUser(); ConfigureViewModel(aspNetUser.ToString()); List<Services> servicelist = db.Services.ToList(); ViewBag.servicelist = new […]

Categories
Development

Issue with my voting system in C# asp.net MVC project. Idea is based on StackOverflow voting system

I am trying to implement a voting system on answers post just like StackOverflow. I am able to do ajax request and everything is stored perfectly as the desired way in the database. But I am facing an issue with my View. In my view, all the answers‘s Html is rendered with one for loop. […]

Categories
AJAX ASP.NET Development MVC

PUT Ajax request returning 404 not found asp.net MVC

I am new to asp.net MVC, I am making one project just like stack overflow. In this, I just want to use the ajax system to upvote or down-vote the answer. So, I can show the counter increase and decrease without refreshing the page. I have default scaffolding one controller of Question in the controller […]

Categories
Development jQuery

JQuery DateTimePicker not validating using Unobtrusive Validation

Using this Jquery DateTimePicker. I want to be sure that the TimeStamp is entered on Submit so in my ViewModel it is a Required field, however, due to how the control is styled, the ID that is Required in the ViewModel is not set on the Input Control, rather the surrounding Div and so the […]

Categories
Development

Dropdown doesn’t load on selected item

I cannot load the edit user page with the dropdown on the option that is selected on the model. It is saved correctly in the db when I add a user. I tried binding it in the edit view but for some reason it is not working. User.cs (the model) public string ActivityLevel { get; […]