Click here to Skip to main content
15,891,253 members
Everything / Programming Languages / Razor

Razor

Razor

Great Reads

by Pete O'Hanlon
Rather than littering a razor component with @if (a == b) logic to show items, use render fragments to make a declarative component
by Ken Haggerty
Scaffold and modify Identity in the new ASP.NET Core 2.2 Razor pages template
by Coding Notes
An introduction to ASP.NET Core MVC
by Ajcek84
Implementation of radar chart for various .NET platforms

Latest Articles

by Victor Sirghii
On the parent razor page, we add Partial View which will serve as the updatable container. On Ajax calls from the parent page, we update only Partial view content, not the whole page, thus creating a smooth user interaction experience.
by Jani Giannoudis
Structured approach to ASP.NET Localization
by Pete O'Hanlon
Rather than littering a razor component with @if (a == b) logic to show items, use render fragments to make a declarative component

All Articles

Sort by Updated

Razor 

N 23 Apr 2024 by Shubham Sawant 2023
In my code i try to download the pdf file of my view by clicking on Export button but unable to download it. I want to download the view same as i see on my browser. I installed iTextSharp.pdf for downloading pdf. IMP: 1. I create a action...
U 21 Apr 2024 by Shubham Sawant 2023
1. In my project i develop resume my fetching data from action method to view. after fetching all data to the view (where i bind my template), i want to download that template with data and design.my all data get's fetched successfully but I'm...
27 Dec 2023 by codiagirl
I have a child view name UploadImage and parent view name CROCOnfig, when I access child view by using button in parent view,it works fine, but when I try to render child view in parent view,it throws error that model is null. I have placed child...
10 Dec 2023 by Graeme_Grant
Is it a commercial project? Will it be over US$1 million pa income? There is this: syncfusion community licence[^] ... a commercial library with a free licence.
8 Dec 2023 by Mark Pelf
I am planning the development of ASP.NET Core MVC Razor application and am looking for FREE library of some quality that supports MVC/Razor development. I see plenty of commercial libraries like Kendo UI that can be used, but I am looking for...
6 Nov 2023 by Maciej Los
I'd strongly suggest to read this: Working with Stored Procedure in Entity Framework Core[^]
24 Oct 2023 by codiagirl
I want to disable double click and allow only single click. I have tried the following code, but it did not work. What's wrong here. I am working in mvc Razor syntax. What I want is, when user clicks on Save letter button, it saves the letter,...
19 Oct 2023 by Dave Kreskowiak
You can just handle the dblclick event and not do anything with it. Test! const btn = document.querySelector("#testBtn"); ...
19 Oct 2023 by M Imran Ansari
To prevent a double-click action, you should disable the button on the first click and then re-enable it after a certain delay. Here is an example of how you can modify your code to achieve this functionality:
9 Oct 2023 by OriginalGriff
Compiling does not mean your code is right! :laugh: Think of the development process as writing an email: compiling successfully means that you wrote the email in the right language - English, rather than German for example - not that the email...
9 Oct 2023 by Graeme_Grant
Still unsure which line is throwing the error... The full error message with stack trace would identify where the error occurred. Have you set a breakpoint and check the line with the error? At a guess, report.InCorrectMapping &/or...
9 Oct 2023 by musfirah hamid
I have 2 accounts one is confirm and other one is unconfirm. whe user click on reportComparison button, it shows data of both accounts. if user think data is wrong he can change it from available dropdowns,dropdown is also on the same page. and...
27 Sep 2023 by Victor Sirghii
On the parent razor page, we add Partial View which will serve as the updatable container. On Ajax calls from the parent page, we update only Partial view content, not the whole page, thus creating a smooth user interaction experience.
16 Aug 2023 by Jani Giannoudis
Structured approach to ASP.NET Localization
9 Jul 2023 by Graeme_Grant
Already answered here: How to store data on ASP.NET razor page using hidden field?[^]
9 Jul 2023 by ahmed_sa
I work on razor asp.net core . I face issue i can't store selected value id and selected text of select option drop down on hidden fields so I need to create two hidden fields first hidden field to store selected value id and second for store...
8 Jul 2023 by ahmed_sa
I work on asp.net core entity framework I have csharp function done using ado dotnet stored proceure i need to convert it using entity framwork core with another meaning how to call stored proceure using entity framework core 6 and i don't...
7 Jul 2023 by Sandeep Mewara
You seems to be missing setting the dropdown value. You setup your table but dropdown is not connected to table default settings. For first time, you need to set dropdown as needed. Add in your script tag in document ready at the end:...
7 Jul 2023 by ahmed_sa
I work on razor asp.net core I need to allow datatable to have paginations options drop down with 5,10,15,20,25 so when load data it must display default rows per page as 10 rows as first page if i need to increase it to 10 or 15 etc it will...
7 Jul 2023 by OriginalGriff
SqlCommand cmd = new SqlCommand($"InsertintoSalesInvoice {InvoiceNum},{ItemId},{qty},{SalePrice},{discount},{AmountAfterDiscount},{Paid},{Remain},{Total},{PaidDate},{CustomerId} ", cn); That's not a valid SQL command, or even close. INSERT INTO...
7 Jul 2023 by A Belal
I want to create invoice Error Is An unhandled exception occurred while processing the request. SqlException: Incorrect syntax near '/'. Microsoft.Data.SqlClient.SqlConnection.OnError(SqlException exception, bool breakConnection, Action...
6 Jul 2023 by Andre Oosthuizen
You can pass the value as a query parameter in the form submission. a Step-by-step can be followed at - How to pass parameters to action methods in ASP.NET Core MVC[^] Create a C# function that will hold, request and redirect the address value -...
6 Jul 2023 by ahmed_sa
I work on an ASP.NET Core razor page. I need to retain value of address on the page after submit, because I check value of Address after submit - it is not retained, and becomes null. I need to retain the value of the Address without resetting,...
2 Jul 2023 by Graeme_Grant
Have you tried setting a breakpoint and stepping through your code, checking variable values to see what is happening? If you are unsure how, please watch this video: Debug JavaScript - Chrome Developers[^]
2 Jul 2023 by ahmed_sa
I work on razor asp.net . I face issue I can't get value of blackprintername on bootstrap model although I get the values of this property on page model but on razor html not display on input text box Black server Ip or black printer name . I...
26 Jun 2023 by Pete O'Hanlon
Rather than littering a razor component with @if (a == b) logic to show items, use render fragments to make a declarative component
24 Jun 2023 by ahmed_sa
I work on razor asp.net core .i face issue selectedbranchid is inside post form form is get selected value without any issue but if i use another post and get selectedbranchid it become null why so How to solve issue please on page model ...
22 Jun 2023 by ahmed_sa
I work on asp.net razor , i get error when try make ajax request to access OnPostshiftDataUp ERROR : Failed to load resource: the server responded with a status of 400 () console.log(formdata) // serialize data ...
20 Jun 2023 by pkfox
Hi All, title says it all, when I launch my site from VS the url set in /Properties/launchSettings.json is used but the file isn't shipped to production, however, I notice whatever url that was in launchSettings.json is used when the site is...
20 Jun 2023 by Sandeep Mewara
First off, launchSettings.json file is only used within the local development machine. Refer: ASP.NET Core launchSettings.json File - Dot Net Tutorials[^] Now, to setup a startup page for ASP.NET Core webapp, there are various ways: 1. Method...
18 Jun 2023 by ahmed_sa
I work on razor asp.net page model . i need to implement tree view with children's checkboxes then submit changes on every parent from selected checkboxes so are you have any sample on razor page asp.net can you help me by provide me sample or...
18 Jun 2023 by Richard Deeming
Here's a nice example of creating a tree view in pure HTML and CSS - you don't even need any JavaScript: Tree views in CSS[^] Adapting that to add checkboxes to each item is fairly simple: ...
18 Jun 2023 by Graeme_Grant
If you are doing this for your own use and not for a large company, then you can use Modern cross-platform ASP.NET Core UI controls | Syncfusion[^] under their community license program: 1,800+ Free controls and frameworks for desktop, web, and...
9 Jun 2023 by ahmed_sa
I work on asp.net razor page model . i face issue i can't edit data table on same page by edit cell without redirect to another page I need to edit cell on same page I need to edit data on table by edit every cell on rows my code details...
8 Jun 2023 by dattaprasaddhuri
I am getting below error while going from one razor page to another:- Quote: An unhandled exception occurred while processing the request. NullReferenceException: Object reference not set to an instance of an object....
4 Jun 2023 by ahmed_sa
I work on razor page asp.net .I face issue I can't show user details using mouse or popover without using bootstrap modal I pass user details using temp data from model to view and data passed success can you apply popover for sample code...
4 Jun 2023 by Mike Hankey
How do you want to do it? Javascript: How To Make a Modal Box With CSS and JavaScript[^] JQuery: jQuery Dialog Examples[^]
27 May 2023 by ahmed_sa
I work on asp.net razor page Login user name and password . I call Web API validate user name and password . my issue I face it I can't receive data returned after login success JSON data returned from web API after success login username and...
13 May 2023 by ahmed_sa
I working on razor page with .NET core 7 . my mainly issue How to pass unchecked checkboxes from html page to page model on post method ? so If I have group of checkboxes not checked so I need to pass it to page model as List on post method...
6 May 2023 by ahmed_sa
I working on MVC razor page with .NET core 7 .I face issue Ajax request not return branches drop down list based on selected value from drop down list country . with another meaning I need cascade branch drop down list based on country drop down...
4 May 2023 by ahmed_sa
I worked on asp.net mvc razor pages . I face issue I can't pass data from page model to view What I have tried: what i try 1- I create view model as public class AddUserViewModel { public int SelectedBranchId { get; set;...
4 May 2023 by mtoha
As far as I know, razor mvc have some HTML function helper. Check this post, and follow instruction. You do not need using foreach. you can use ViewData['listOfBranch'] containing data of branches 81 data at your case. usage to show select...
23 Apr 2023 by Member 13998042
Dear team i am trying to save a textbox value in db using ajax which is inside the jquery datatable . My Datatable is below $(document).ready(function () { var empid = '@ViewBag.empid'; $.ajax({ ...
4 Apr 2023 by Member 13998042
Dear mentors i am working on a asp.net core mvc .net 6 project where i have a view in which i am making a ajax call to load data to a datatable the ajax call and the datatable loads script is as follows function fetchIndexforhrvalidate() { ...
25 Mar 2023 by Shaun C Curtis
How to build a Modal Dialog for Blazor
6 Mar 2023 by Member 15061985
How do I get a simple modal dialog to work in a Visual Studio 2022 Razor Server Application? To get started this is what I have done: • Open visual Studio • Create new Project • Select Blazer Server App Project Template • Modify the...
19 Feb 2023 by Member 13998042
I have a view which return a model in list . My view is as follows @foreach (handbook.Data.EmpDoc files in Model) { @if...
19 Feb 2023 by Richard Deeming
Since the remarks are related to the employee rather than the document, you'll need to create a view-model containing the remarks and the list of documents. For example: public class EmployeeInformation { public int EmployeeId { get; set; }...
17 Feb 2023 by Ehsan Sajjad
You need to just take care of setting the name of the checkboxes properly and you should be able to read the values in the post. You can try something like below and it should have values posted in the controller action ...
17 Feb 2023 by Member 13998042
I have a view which shows the list of files from a folder and the file count may differ for every user my view is as follows
6 Feb 2023 by Member 13998042
I have a view as follows @if(Model.Is_Prefix_Checked == 1) {
25 Jan 2023 by Deepak Kanswal Sharma
Hello All,I'm Trying to upload Image with other details along with other details , but it gives me this error :-String[4]: the Size property has an invalid size of 0.Stored Procedure is:-ALTER proc [dbo].[spInsertPageDetail]@Heading varchar(100),@Body varchar(2000),@Img...
9 Jan 2023 by Graeme_Grant
Answered here: How to select values inside multiselect?[^]
9 Jan 2023 by Member 14673641
How to select values inside MultiSelect (Bootstrap)? I want to sellect values inside Colors_SELECT by using a string result. Issue: I wote the following code but it doesnt select anything. Why `Colors.Add(TempArray[i]);` is not working? Form ...
9 Jan 2023 by Graeme_Grant
Google Search is a great research tool. I did a quick Google Search: asp.net mvc multiselect dropdown - Google Search[^] Found many examples like this one: ASP.NET MVC 5 - Bootstrap Style Multi Select Dropdown Plugin[^]. If this is not...
3 Jan 2023 by Graeme_Grant
I did a quick Google Search: c# mvc form file example - Google Search[^] Found this accepted solution: MVC: How to post File Upload and other form fields to one action [solved] - StackOverflow[^] UPDATE I have put together a sample app to...
3 Jan 2023 by Sascha Manns
I'm build a .NET 7 blog with MVC and Razor-Pages. My model is: using System.ComponentModel.DataAnnotations; using Microsoft.AspNetCore.Http; namespace MannsBlog.Models { public class ContactFormModel { [Required] ...
13 Dec 2022 by Member 13998042
what i am trying to do is that on a event of checkbox clicked i want values from one text box to appear in another text box and the second text box should become disabled. What I have tried: @model...
13 Dec 2022 by Richard Deeming
Your script is extremely confused, and has several syntax errors. Based on the vague description, you're looking for something like: const isPhoneSame = document.getElementById("getPhone"); const personalPhoneNumber =...
27 Nov 2022 by Thomas Frink
I am working on updating an ASP core 2.0 razor page, but cannot set the focus to an input element. I have tried razor, ASP, and HTML, but not seem to work. Hopefully, someone can point me in the right direction. I have two inputs on a partial...
27 Nov 2022 by Richard Deeming
Sounds like you're looking for the autofocus attribute: autofocus - HTML: HyperText Markup Language | MDN[^]
12 Nov 2022 by Brian C Hart
Hi, I would rate myself as somewhat an experienced web developer, however, most of my expertise focuses on the back-end/busiless logic layer sides of websites. Usually, the graphic-design of my website is left to someone else on the team who generates beautiful jQuery/JavaScript/AJAX enabled...
8 Nov 2022 by Member 15825061
I am including a Foreach in a razor page that returns the results fine, but I am only getting one row, one column for each result. I would like to create a column of 4 per row and create a new new row every 4 items returned. I have move...
8 Nov 2022 by Richard Deeming
Move the outside of your foreach loop: @foreach (var item in Model.ResourceType) {
17 Oct 2022 by DougsSoftware
I am new to Blazor and Razor. When my Blazor webpage starts up, I want to execute code in the "Load event" that will click the first list item (id="li_for_APage") so that the @Body will contain APage. But I can not find the "Load event". The code...
17 Oct 2022 by Gregory Baughman
Ironic that I googled the same thing, and came here to a link to a dude telling me to google it.
18 Sep 2022 by towaso
A short example on how to create a hierarchical web checklist
11 Aug 2022 by Harvey Saayman
The ultimate goal here is to build a dynamic, user editable dashboard in my system, more or less like the one in the Azure portal. At present all my dashboard widgets are already self contained ViewComponents, they make Ajax calls to get their...
25 Jul 2022 by Adam Jones
How Can i make the EditorFor input disabledi have tried using the below which doesn't work@Html.EditorFor(model => model.TaskName, new { disabled = "disabled", @readonly = "readonly" })
25 Jul 2022 by Member 15717891
@Html.EditorFor(model => model.Issued_CreatedBy, new {htmlAttributes = new { disabled = true, @class = "form-control ", @Value = Session["Username"] } })
15 Jul 2022 by Graeme_Grant
I can't see what html is being rendered, so it makes it difficult to see the full picture of what is happening. At a guess, the header/navbar is using class app / position: absolute;. Your Content container element has margin-top: 0;, electively...
15 Jul 2022 by Member 15341738
Hello, I am now working on a .NET MVC app and have a problem with my partial view. It renders within main view, but the top of the partial view which I mentioned before is being cut at the top. Here are pictures: This is how it looks now This is...
30 May 2022 by Sam Hobbs
I converted my website from an ASP.Net website to an ASP.Net Core website and now I realize that none of the pages other than the home page is using the layout. The ASP.Net Core website is at Sam's Simple Samples - sswa (it currently loads...
14 Apr 2022 by Member 12885549
I have functions to view/remove data: [HttpGet] public IActionResult Index() { ViewData["table1"] = _repository.GetAll("table1").ToList(); ViewData["table2"] = _repository.GetAll("table2").ToList(); return...
14 Apr 2022 by Dave Kreskowiak
There's a limit on the size of the request. See c# - Increase upload file size in Asp.Net core - Stack Overflow[^]. Be sure to read ALL of the answers before tinkering with your code. There's multiple possible solutions depending on your exact...
9 Mar 2022 by Coding Notes
An introduction to ASP.NET Core MVC
26 Jan 2022 by Sni.DelWoods
My edit view uses partial views to edit different addresses. On submit, the form keys are identical for street and are not assigned to the model. I get: Street[0]: Silicon Road Street[1]: Main Avenue I need something like: customer.Street:...
25 Jan 2022 by Richard Deeming
Use the tag helper instead of the PartialFor extension method: @Model EditForm ...
25 Jan 2022 by M Imran Ansari
You can modify your code in respectively like: EditForm.cshtml @await Html.PartialAsync("AddressEditPartial.cshtml", @Model.Order) AdressEditPartial.cshtml @Model Order
21 Dec 2021 by Madhukar Krishna 2021
I want to create a simple list of string in view, submitted from textbox, using submit button, without using model, using razor. I want that on every submit a new string in the list is created. I am trying the following code but it just creates...
16 Dec 2021 by Member 12885549
I have view is C#: @{ var itemList = (List)ViewData["itemsList"]; } @if (itemList != null) { var id = 0;
22 Nov 2021 by Tshumore
I have an EF6 MVC application which I intend to do update operations but I am having issues on 1) how to edit Dropdown values 2) how to edit Date values 3)Assign default values for edit properties I am able to create an AssetRequest entry as...
5 Oct 2021 by Member 10188021
When I run the Blazor project, the jquery table does not work at all, but when I use the following code in MainLayot.razor: protected override async Task OnAfterRenderAsync(bool firstRender) { if (firstRender) { await...
24 Sep 2021 by KarNullKa
Is it possible write descriptions for a custom TagHelper? In C# code is possible something like this: /// /// Desctiption /// public class NewClass But how to write description for html elements like tag and its...
20 Sep 2021 by KarNullKa
I'd like to find where they're stored files (or paths) like javascripts, css, images. By write I mean for example If there is a collection in the root cshtml...
20 Sep 2021 by Richard Deeming
Simple: the file is called table.css, and it's in the css folder in the root of your site. Since you haven't explained what you mean by "collections" and "this object", we can't tell you anything else.
14 Sep 2021 by Member 13964245
Hi, Iam new to blazor and working in it. I want to capture the image from video (webcam) and scan the image. Using javascript, function accesscamera(id) { let camera_button = document.querySelector("#start-camera"); let video =...
7 Sep 2021 by KarNullKa
In the component view library project, my tag helpers are not working. The view works, but in the VS2019 editor the tag helpers don't work. What I have tried: In the test project for the library the tag helpers work there is a _ViewImports file...
2 Aug 2021 by Pete O'Hanlon
Fourth part of a series of articles where we build an application showing the entire thought process when writing it
31 Jul 2021 by Matthew Dennis
I found the videos at Blazor Train[^] to be very useful when trying to understand Blazor. Nice bite sized chunks of focused information. Also you might check out Chris Sainty - Building with Blazor[^]. He is literally writing the book.
30 Jul 2021 by OriginalGriff
Google is your friend: Be nice and visit him often. He can answer questions a lot more quickly than posting them here... A very quick search using your subject as the search term gave 12,000 hits: Where is the "load event" in blazor? - Google...
24 Jul 2021 by DougsSoftware
Hi, I have a problem calling an ASP.NET API from my Index.cshtml file. I think the problem is in my Index file's action. My understanding is that the action is suppose to call the controller (I am new to this). When I click on the Choose file...
14 Jul 2021 by Codes DeCodes
I have a partial view inside which loops my Availability object for getting values from text box. I have added my code in here. My model class: public class Availability { public int ID { get; set; } public string Name{ get; set; } public string Address { get; set;...