Questions tagged [razor]

Razor is a template language used by ASP.NET Web Pages and ASP.NET MVC (since version 3). 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.

Filter by
Sorted by
Tagged with
0
votes
0answers
4 views

Azure .Net Core Web App looking for Razor Runtime 3.0.2.0 which doesn't exist

I attempted to downgrade a Microsoft Asp.Net Core Web App from .Net Core 3.1 to 3.0.2. It ran beautifully locally, but was failing to start up on Azure. I assumed that Azure didn't have support yet ...
-3
votes
0answers
30 views

NullReferenceExeption there, where it cannot be (Blazor) [duplicate]

Im trying to create simple EF core Razor application, but this bug finally dissapoint me Please, dont close this question with *the link on trivial exeption, it is not the same situation, becouse: ...
0
votes
0answers
3 views

Is there a Storybook.js for .net razor?

In particular I'm using asp.net awesome controls, but if telerik controls work with a 'component explorer' than that setup might be good for me too.
0
votes
0answers
10 views

GenerateRadioButton will not render as selected

I have a custom tag helper that renders a radio list. Everything works great except I cannot get the tag helper to render with the option selected when rbSelected=true. bool rbSelected = true; ...
1
vote
2answers
29 views

How to split Blazor WASM components code of C# and HTML in different files? [duplicate]

I've some background in Web Development, mostly in ASP MVC and JavaScript with Angular. Currently, I'm learning Blazor WASM and I'm somehow "confused" because I cannot find any example of how to ...
2
votes
0answers
34 views

MVC @Html.HiddenFor renders html form with no value

Caution, before You read the rest This question is not about POST method, redisplaying view with submited form or binding input values to controller method parameters. It's purely about rendering the ...
0
votes
0answers
18 views

Is it possible to show/access a hyperlink inside TextBoxFor?

I have a text box as below to store a document link and I want to show the text as a hyperlink if user copy & paste any url in the text box to click & view/navigate the path easily. Is it ...
-1
votes
0answers
6 views

What is the best library to display data tables in MVC and Razor? [closed]

I am currently using DataTables but I think there is not much documentation and it has become a bit old. Someone recommend one that goes better. Thanks in advance.
0
votes
1answer
29 views

How to use the same singleton instance in Razor pages?

I'm writing an ASP.NET Core app and ran into the peculiar problem that my Razor pages seem to use different singleton instances than the rest of the app. The problem manifests itself by showing no ...
-3
votes
0answers
24 views

Problem with Login Controller and the Context Error in userDetails

My LoginController: [HttpPost] public ActionResult Autherize(Verwaltung.Models.Login userModel) { //LoginContext = Datenbank verbindung aufrufen using (...
0
votes
0answers
38 views

Modelstate is returning Isvalid = false on a valid object

I am using asp core 3.1 razor pages. On one of my page am posting JSON to razor pages post action. The model binding works perfectly. My issue is when I call ModelState.IsValid always getting false ...
0
votes
0answers
17 views

Object reference not set to an instance of an object LINQ join 3 tables [duplicate]

Im trying to write a LEFT JOIN query to join 3 tables using this reference. I have a Stock table, Product table and Image table. Both the Product and Image table are populated with related data, the ...
0
votes
0answers
17 views

How to write an extension method for a razor page

I want to create an extension method that I can reference in a Razor page and includes both IHTmlHelper and IViewComponentHelper within it's context. Background In a Razor page, you can call code ...
0
votes
1answer
29 views

Can I make jQuery read tag helpers of ASP.NET Core 2.1 ? Seems it's completely ignoring them

Can jQuery read the asp-for tag helpers and asp-action? It seems from what I've seen that just ignores them how can I get around this problem or solve it? (I can't change jQuery approach). What can I ...
0
votes
0answers
19 views

How to pass value and text in w3schools autocomplete to asp.net mvc

I have a list of clients that have a name and a id when the user selected a client id (cliente_id) only returns the name(nombre_cliente) but I would like to have the id as well. I am using the ...
-1
votes
1answer
20 views

write c# code in JavaScript function in Razor [closed]

my question is very short want to this : $(document).on('click', '.ee', function(){ $('.b').val("@Model.Result.GoingDate.AddDays(-1).ToString()"); @{Model.Result....
0
votes
1answer
33 views

Blazor Multiple change events not updating property correctly

I am new to blazor, and excited to start trying it for some of our internal applications, however I am having some trouble understanding the binding/change events. Starting with a new Blazor project I ...
0
votes
2answers
52 views

@Html.EditorFor targeting wrong property

I am having razor view where i do edit my data. Classes i do have are like this: public class A { public string Value1 { get; set; } public int Value2 { get; set; } public A() { ...
1
vote
1answer
33 views

Different Hidden Fields Gets Same Value In Asp.net C# Razor

I have an action which looks like this: public ActionResult NewPicture(int id) { var response = service.Get(id); if (!response.Succeed) return Error(response.MainError.ErrorType); ...
1
vote
1answer
20 views

Cant bind RouteValueDictionary as HtmlAttributes to EditorFor

I'm trying to make a simple HtmlHelper to create a EditorFor that deal with List<T> index childs. I did some like this public static IHtmlString EditorFor<TModel, TValue>(this HtmlHelper&...
0
votes
0answers
13 views

Using Razor to populate Ajax json response

I am new to .net core and Razor pages, so please excuse me in advance for perhaps asking a stupid question: For Ajax requests as of now, I have only seen using vanilla JavaScript or jQuery for ...
0
votes
0answers
17 views

MVC get dropdownlist selected value to TempData

I am using an MVC model and i want to save the selected value from a dropdownlist. here is what i have so Far Model. namespace FormsAuthenticationMVC.Models { using System; using System....
0
votes
0answers
22 views

Why is HttpContext null in razor component?

I'm using HttpContext from IHttpContextAccessor in a dotnet core 3.1 web app in a couple of scenarios. It is always set as I would expect. However, HttpContext is always null when injecting ...
0
votes
1answer
17 views

How to close html tags in cshtml in Asp.net core

Is there a way to close HTML tags if it is outside a foreach statement in the cshtml file? Below is a simplified version of what I am trying to do. Basically I open the tag inside the loop and want to ...
0
votes
1answer
20 views

How can I get my jquery autocomplete to fill in multiple fields in MVC?

I am trying to setup an autocomplete in jquery that gets information from a user in Active Directory. A user can type in a few letters of a person's last name, and what returns is a 2D list (List>) ...
0
votes
0answers
20 views

HTML textbox is resetting itself after 5 characters. What may be causing this?

Using an MVC Razor table for users to input various pieces of info. One column has text inputs. I want to add comma's to every third character while they're typing. I'm using a library called ...
1
vote
1answer
35 views

What is that @{} mean in .cshtml?

Don't be wrong, I know it's c# code inside it. I am new at Asp.Net Core Web apps with Razor pages. And I try to understand if what's inside @{} is working on server or not. I'm not really sure how to ...
0
votes
0answers
10 views

Summernote store text without the html tag using Razor in asp.net mvc

Summernote stores the data without html tag using Razor syntax in asp.net mvc core. What can I do? Can I filter the tag in c# code or in html itself?
0
votes
2answers
29 views

How to do nullable control the most effective?

To .cshtml coming price null and returned error "Object reference not set to an instance of an object." @foreach (var product in ProductsModel) { <tr> <td>product.ProductName&...
0
votes
0answers
23 views

Binding values to display:hidden elements

If I create a form where some elements have display:hidden on them will the values in those elements get passed to my controller when the user clicks the submit button? For instance, given a ...
1
vote
1answer
27 views

Display value from related table in View

I have created a model with an MVC 5 Internet Application and then added in ADO.Net Entity Data Model > Code first from Database. I have added a foreign key in a newly created table linking to the ID ...
0
votes
2answers
52 views

Changing font colour conditionally in MVC

I'm new to MVC and still learning the best way to go about things. My problem is I want to change a font colour conditionally. For example, if something gets deleted. I want the font colour of the ...
-1
votes
2answers
55 views

Why isn't my form posting any data even though I've set the name property?

So I'm trying to post a form with some data, but for some reason when clicking the button that POSTS the data, I'm not getting anything serversided, all the values are NULL. As you can see it's a ...
0
votes
1answer
32 views

MVC Razor view displays the wrong time value of a DateTime object

I have an Order object, that contains two DateTime attributes called LendDate and ReturnDate as seen below: public class Order { public DateTime LendDate { get; set; } public DateTime ...
1
vote
1answer
32 views

Add blur on non-input div fields not working

I'm trying to match the styling that bootstrap applies to input fields to a parent div. I've removed the said :active and :focus styling from the child input elements and am trying to use the ...
-1
votes
0answers
24 views

Routing Area in ASP.Net Razor Page .Net Core

I have a problem in area at ASP.NET Razor Page .NET Core, I have some expressions in ASP.NET MVC and I use area in my old projects but after joining in a new group they use .NET Core and ASP.NET Razor ...
0
votes
1answer
18 views

Razor code blocks not working in ASP.NET core 3.1

The @Helpers is gone from Razor in ASP.NET Core 3.1 and now as an alternative suggested to use Razor code blocks. https://docs.microsoft.com/en-us/aspnet/core/mvc/views/razor?view=aspnetcore-3.1#...
0
votes
3answers
47 views

Best practice to read child component value

I have created a Razor component, a simple input type like this: @using ComponentPackage.Common <input type="text" @bind="InputValue" /> @code { [Parameter] public EventCallback<...
0
votes
1answer
28 views

Bootstrap show only badge on small screen

I have a dashboard (MVC Razor + Bootstrap) navigation bar with these labels and badge <span class="btn btn-danger" style="pointer-events: none;">Alert<span class="badge badge-pill badge-...
0
votes
1answer
38 views

List Items Not Showing When They Are All DIV Tags

I have a cshtml page that has a list of images in DIV tags. It looks like this: <div id="ActionButtonContainer" class="containerRight"> <div id="ActionButtonSidebar" ...
0
votes
1answer
43 views

Blazor component is initialized, but not visible?

I am working a bit with blazor right now and got to a pretty weird fault. So, I´ve got a parent component, which is having a child component and this is having a child component itself, both giving an ...
0
votes
1answer
26 views

call a c# functions in cshtml when Ajax.BeginForm completed

so have an Ajax.BeginForm that call a PartialView and return a view (which I'm using it for filtering the products) but I want to change the main view Model too I mean after the Ajax.BeginForm got ...
1
vote
3answers
48 views

Access model property from javascript

I have an ASP.NET MVC project and I am trying to access a model property (isNew) from the view (.cshtml) and from within javascript function so I am performing below without success: @model My.Common....
0
votes
0answers
12 views

Javascript form validation not working properly once published in IIS but works in development (IIS Express)

I have a web app ASP.NET core 2.0 in MVC, with that there's a form validation on POST method in controller. Specifically the JS should work like this: I click on a drop down, if I select "others" an ...
0
votes
0answers
20 views

@inherhits in razor files with ASP.NET Core 3.1

I am trying to use a custom base class for my razor files in ASP.NET Core 3.1 by using @inherits in the cshtml file. Unfortunately Visual Studio 2019 as well as msbuild do not recognize, that a custom ...
0
votes
0answers
12 views

How do I create a Razor syntax code analyzer?

Is there any guidance or examples of code analyzers for Razor code? For example, if I want to catch all <script> blocks that point to external sources without a asp-fallback-src attribute? I'...
0
votes
2answers
86 views

Post from Razor page clears Model values - when it shouldn't?

I have a simple single page ASP.NET Core Razor app that has a "select" in it that I am populating from a Model variable. The values in the Model variable are cleared by the time that I examine them in ...
1
vote
1answer
35 views

Adding to a List of objects from the View

What I wanted to do was seeming simple but I am having a bit of trouble. I've created the following class: // SelectedItem.cs public class SelectedItem { public Brand Brand { get; set; } ...
0
votes
1answer
28 views

Retrieving data from a database in ASP.NET Razor Pages

I found online how to submit an image uploaded from the user into my database. Here is the code that I use: Create.cshtml @page @model SummerFling.Pages.Products.CreateModel @{ Layout = null; } ...
2
votes
1answer
39 views

Blazor (c#) DXDatagrid (devexpress) : Problem with Master Detail editor when replacing the default command buttons with icons

I created a C# project using Blazor and Devexpress DxDataGrid component to create a Master Detail View. Everything works fine using the default command buttons (New, Edit). When I replace the Master ...