Questions tagged [razor]
Razor is a template language used by ASP.NET Web Pages, ASP.NET MVC (since version 3), and ASP.NET Core. It adds a layer of abstraction above HTML generation. It supports seamless transitions between HTML markup and C# or VB code. Transitions between markup and code are indicated by the "@" sign.
razor
33,294
questions
0
votes
2
answers
35
views
How to get container of model in EditorTemplate, ASP.NET Core 8.0
I'm looking for possibility to retrieve container in EditorTemplate (ASP.NET Core 8.0).
In .NET 4.6 there is property for that:
ViewData.ModelMetadata.Container
but there is no such property in .NET ...
0
votes
0
answers
8
views
DNN Razor Host Module - How to use a querystring parameter as a variable to get data related to a specific UserID
I need a syntax help to write the following code to use in Host Razor module on a dnn site version 9.13.
I need to use a querystring parameter as a variable to get data related to a specific UserID.
@...
2
votes
1
answer
28
views
Strange Strings in HTML Code of New ASP.NET Core Razor Projects in Visual Studio 2022
I'm encountering an issue when creating new ASP.NET Core web app (Razor) projects using Visual Studio 2022 (Community Edition 17.10.4) with .NET 8.0. Without making any modifications, I see strange ...
1
vote
1
answer
32
views
Different authorization for one folder page than for the rest of the folder in ASP.NET Core Razor
Using ASP.NET Core identity, I'd like to allow an authorized user ability to change their password, but require the policy "Admin" access to access the other Account Manage pages.
However, ...
0
votes
1
answer
34
views
dropdown MVC don't keep focus for selected option
I have asp net core mvc application. After clicking filter controller recives propper data, but drop down always shows All option:
@{
ViewData["Title"] = "Index";
IsOpenFilterState ...
0
votes
0
answers
29
views
In one of the cshtml files,namespaces can not be found
I am using visual studio 2022 .net 6. All the other cshtml files within the same project are not showing any issues. Only in one cshtml file, the namespaces are not able to be found. All the ...
0
votes
1
answer
45
views
How to populate CreateGroupViewModel
I'm having trouble with inputting value into a ViewModel as it keep returning null after the value is inputted via cshtml.
Value I input in cshtml
After hitting confirm
CreateViewModel.cs
public ...
0
votes
1
answer
31
views
How do I use cshtml links inside a controller class?
I have an older ASP.NET Core 2.1 web app project.
I have a .cshtml page in this folder in my project:
G:\Projects\AccessApp\Pages\Privacy.cshtml
And I want to use it in my controller. I've tried the ...
1
vote
1
answer
33
views
How to conditionally render style attribute in Razor template without causing NullReferenceException?
I am working on a templating project using C# and Razor Engine (Razor Templating Engine). The objective is to create React code using my own JSON definition.
My AppDefinition.json looks like this when ...
1
vote
1
answer
48
views
Blazor properly updating the UI after an API call
This code does exactly what I want:
Displays a message (div) from the robot saying thinking
Waits for the API call to complete updates that message (div) and scrolls to the message (div)
It feels ...
0
votes
1
answer
39
views
How to avoid bootstrap labels to overflow the date picker input on .NET 8?
I'm following the Microsoft Identity tutorial on adding custom attributes to the identity user. I've added the proposed changes by the microsoft docs, however I'm getting a small visual error.
Code is ...
0
votes
1
answer
29
views
Memory leak after adding AddApplicationPart and EmbeddedFileProvider
I have an ASP.NET Core 8.0 application where I want to move some controllers into a module (separate project). To accomplish this I had to update the startup from:
services.AddControllersWithViews()
...
0
votes
0
answers
30
views
ASP.NET MVC datepicker doesn't show calendar
I'm trying to add datepicker, however when I try to use @html.TextboxFor, the calendar is not popping up. As for EditorFor to input="date" options, they show mm/dd/yyyy format when I need dd/...
1
vote
1
answer
47
views
Conditional not working in ASP.NET Core 7 Razor view
I have a search function on my site, and one of the options the user has is to select the type of search.
So given this example in a view:
@using System.Data
@model DataSet
hello, world
<br />
@...
0
votes
1
answer
39
views
How to use razor renderer in .NET 6?
In my .NET 4.8 Web API application, I take an externally received HTML formatted string and convert it to a .cshtml file using Razor Engine, then append it to my page with JavaScript. I do this using ...