Returning a partial ActionResult allows us to update content on a page without reloading the page. This simple example lists some students and allows us to display detail about a student with a click. We use entity framework and .net core. In this example, the students are listed with a button next to each student. […]
Uploading an image to a file using javascript and entity framework
You can use javascript to resize a photo before posting to entity framework. The following html is included in a form with the id “formdata” and adds bootstrap for formatting. Form Html <div class="form-group"> <label asp-for="Photo" class="control-label"></label> <label class="control-label">Upload a photo</label> <div class="col-md-10"> <input type="file" name="Upload" id="Upload" onchange="loadImageFile();"> </div> <div> <img id="my_photo" src="@src"> </div> […]
Using the .net core anchor tag helper with Razor Pages and areas
With Razor Pages, the anchor tag helper is used somewhat differently than with MVC. A typical anchor tag helper for MVC is: <a asp-controller="Home" asp-action="Products">Our Products</a> In this case, you specify the controller as the Home controller and the handler method in the controller as “Products”. Razor Page Model In the case of a Razor […]
Preview a photo before upload in a Razor Page
When you upload a photo to your website, you want to see a preview before you click “save”. This discusses a simple way to temporarily upload a photo with ajax so as to make a seamless process that does not require your web page to be refreshed. You can also preview your photo without temporarily […]
Endpoint routing in .net core 3.1
The routing process has changed in newer versions of .net core MVC. You can route either with attribute routing or with conventional routing. However. it can be confusing if you use both. In this example, I set up examples of both types. Example: Routing a privacy statement This example is to direct to a privacy […]