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 ...
0
votes
1
answer
63
views
Text input into List in cshtml
How can I turn a text input separated by comma in html into a list of a model that I created and add the values into a sql-table
Models
public class Person
{
[Key]
public string PersonId { get;...
-1
votes
0
answers
20
views
2sxc get string resource from another language
In lastest 2sxc, In razor template, how can I get resources from a specified language? For example: The current website is still in en-US language, but I want to get the value of a label of another ...
0
votes
1
answer
74
views
CSS for bootstrap accordion
So I'm pretty new to css and bootstrap, and have added an accordian into my view page. I have tried to alter the original css but with no luck!
<div class="accordion accordian-flush" id=&...
0
votes
1
answer
33
views
[Blazor Razor pages I am working on the login/register of a website and these error codes popped up: CS0120 and CS0117
I am creating a website/blog with a register/login/logout feature. I am almost done, but having a hard time with the Identities on the .Net8. The scaffolding feature changed and there were no YT ...
0
votes
0
answers
16
views
Footable: How to render same hidden columns multiple times within a single row
I am using row expand feature of footable to show hidden columns within a row (on click).
What I have/Issue:
I have same column description which is repeating 4 times (as it has 4 services associated ...
0
votes
0
answers
33
views
How to autopopulate fields from razor view page
I have already created a view that displays data in a razor page (5 columns)
studentFirstName, StudentLastName, StudentId, CourseId, Grade
It also displays a button (instead of default Edit link) ...
0
votes
0
answers
27
views
How to display text input box over modal in abp framework?
I have the following code which is a modal element. The "NewButton" element is supposed to trigger a text input box in which the user writes the reason for the delete action. The Scripts ...
0
votes
0
answers
23
views
Submitting a form from a website to an external Kali Linux server to run a python script
As part of my school project, I am trying to create an automated vulnerability tester website which takes in a user input as URL and this URL will be submitted over to a kali back end, which will run ...
-1
votes
0
answers
19
views
Unable to render FusionTime charts in Blazor
I have built a Blazor app that renders FusionCharts, connecting to a SQL Server database. I have successfully created regular FusionCharts and linked them to the SQL Server database. Additionally, I ...
1
vote
1
answer
63
views
ASP.NET Core MVC web app : antiforgery tokens
I am wondering if anyone can help me. I am trying to get [ValidateAntiForgeryToken] action method to fire and it appears not be. I was trying to check if the anti forgery token logic was actually ...
0
votes
0
answers
35
views
Issue with RadioButtonFor in Index.cshtml - ASP.NET MVC 5
In my Index.cshtml in ASP.NET MVC 5, I have the following code and it works fine.
<div>@Html.DisplayNameFor(model => model.IsEnrolled) Enrolled </div>
But, if I replace the same code ...
0
votes
1
answer
22
views
razor library loading views from different location
My app implements plugin system (razor libraries). App is using razor runtime compilation. Razor library contains few ViewComponents with custom structure described below.
Razor library structure:
...
0
votes
0
answers
41
views
Is it possible to create dynamic ASP.NET Core Razor view and controller file during runtime?
My requirement is to create dynamic razor view and controller save at project location at run time. If I call newly created controller then it will render newly created view also. The files are ...
0
votes
0
answers
18
views
Razor RuntimeBinderException - ViewBag object is null, even though it's not
I'm working on converting a project from .NET 472 to .NET8. All this code is for .net 8 web app
I need to render a razor view into html so that I can then convert it to a PDF. I have the code to do ...
1
vote
0
answers
38
views
Converting UTC time in model to Local time in view
I have a C# model that includes a list of items, and each item has a DateTime property containing a time that is represented as UTC.
I need to render those times to the UI, which is a cshtml page, and ...