Make an object available from dependency injection via more than one type

Advertisements I have the following interface and classes. public interface IWorkingPath { string WorkingFolder { get; } } public class WorkingPath : IWorkingPath { public required string WorkingFolder { get; set; } } public class AppSettings : WorkingPath { public bool IsStaging { get; set; } public bool IsStagingTrackAndTrace { get; set; } } And… Read More Make an object available from dependency injection via more than one type

Calling Razor Pages method via ajax not working

Advertisements I’m trying to call a Razor Pages method from ajax but it ends up just calling the OnGet() method of the page. The url seems right as it’s https://localhost:7100/?handler=SearchCityState&cityTerm=Det The method I want to call is in the Index.cshtml.cs file and the name is correct. It’s defined as: public async Task<IActionResult> SearchCityState(string cityTerm){ …… Read More Calling Razor Pages method via ajax not working

C# Razor syntax

Advertisements <div class="field"> <label class="label"> Priorirty </label> <select style="width:100%" asp-for="Priority" class="form-select"> @if (Model.Priority == "Green") { <option></option> <option selected="selected" style="color: green" value="Green">Green</option> <option style="color: orange" value="Amber">Amber</option> <option style="color: red" value="Red">Red</option> } @if (Model.Priority == "Amber") { <option></option> <option style="color: green" value="Green">Green</option> <option selected="selected" style="color: orange" value="Amber">Amber</option> <option style="color: red" value="Red">Red</option> } @if (Model.Priority == "Red")… Read More C# Razor syntax

Ajax file upload in .Net 6 Razor pages sends Null in the codebehind

Advertisements Already tried This Answer but it did not work. So seeking help. I have a .Net 6 Razor page from where I am trying to upload a file. Here is my AjaxFileUpload.CSHtml <h3>Ajax File Upload</h3> <form method="post"> <div class="mb-3"> <label for="formFile" class="form-label">Select File 1</label> <input class="form-control" type="file" id="formFile1"> <br/> <button type="button" class="btn btn-info" onclick="UploadFile1ViaAjax()">Upload… Read More Ajax file upload in .Net 6 Razor pages sends Null in the codebehind

Bootstrap Borderless Table Still Has Border?

Advertisements Pretty new to Boostrap and cannot figure out what may be triggering this line on my Create view and how to eliminate it. Here is a portion of my view pertinent to that area: <h3 class="text-primary pl-3">Client Demographic Information</h3> <table class="table table-bordeless" style="width:100%"> <tr> <td style="width: 30%"> <div class="form-group, mb-3"> <label asp-for="Incident.CaseType"></label> <br />… Read More Bootstrap Borderless Table Still Has Border?

Why when you click on input, nothing happens in the form?

Advertisements I’m making a small page where you can create users, change their password and delete them. The creation works well, but deleting and changing the password does not respond to clicking in any way. It works correctly through the postman. What could be the problem? @page @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers @{ Layout = "Shared/_MonitoringLayout"; ViewData["PageTitle"]… Read More Why when you click on input, nothing happens in the form?

How to Format Search String to Return Part of Search String From More Than One Column in Razor Page Table?

Advertisements I have a data table that I would like to filter via a Search box on my razor page. Here is my current code: if (!String.IsNullOrEmpty(searchString)) referral = referral.Where(s => s.BoardMtgMonth.Contains(searchString) || s.BoardMtgYear.Contains(searchString)); So, one column in the table (BoardMtgMonth) has month values: January, February, March, etc The other column (BoardMtgYear) has year values:… Read More How to Format Search String to Return Part of Search String From More Than One Column in Razor Page Table?