Skip to main content

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
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 ...
46 votes
3 answers
42k views

Is it possible to display raw Html from database in ASP.NET MVC 3?

I have a table in my db where one of the properties is an Html page (without the html, head and body tags), and I intend to put it in the middle of one of my views - say, I call a cotroller method ...
1 vote
2 answers
3k views

Kendo UI grid aggregate using groups and Razor syntax getting 'sum' is undefined error

i have one parent grid for telerik and under that have the aggregate grid as a child grid , here is my code here is the parent grid - @(Html.Kendo().Grid<ClaimListbyCompanyUserId1_Result>() ...
0 votes
2 answers
2k views

React component doesn't render in a razor page

I have a react component and i want to render it in a razor page. But i don't want to be rendered in a div. Cause i know it's works with ReactDOM.render. But it's not what i want. I must use it as a ...
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
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
444 views

How to include font-awesome (that was instolled via nuget) in my layout in a .Net Core project?

I have a simple .NET Core project with the following .csproj file: <Project Sdk="Microsoft.NET.Sdk.Web"> <PropertyGroup> <TargetFramework>netcoreapp2.2</...
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 ...
204 votes
9 answers
222k views

Mix Razor and Javascript code

I'm pretty confused with how to mix razor and js. This is the current function I am stuck with: <script type="text/javascript"> var data = []; @foreach (var r in Model.rows) ...
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
3 answers
1k views

Using "href" to link a tiktok page. Tiktok URL use "@", but get error in cshtml

I want to link a tiktok page in a cshmt project using "href", but I think that because of the "@" that tiktok has by default it is giving error. I tried to use the two syntaxes ...

15 30 50 per page
1
2 3 4 5
2221