The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Questions tagged [razor]

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

Display all files in a folder (object) along with nested subdirectories part 2

Previous post: Display all files in a folder (object) along with nested subdirectories Task: Given a main directory/folder, list all the files from it and if this directory contains nested sub-...
4
votes
1answer
149 views

Display all files in a folder (object) along with nested subdirectories

Follow-up question: Display all files in a folder (object) along with nested subdirectories part 2 Task: Given a main directory/folder, list all the files from it and if this directory have other ...
3
votes
1answer
881 views

Notification system

I would like to implement a mail notification system Notification.cs ...
1
vote
0answers
53 views

Volume control with using asp mvc 6

General purpose of this training project is to control sound volume on remote machine (which exposes ISystemControlClient through web service). It's created using ...
1
vote
0answers
53 views

Get typed results for examine indexer using Umbraco

Continuing on this question on Stack Overflow, I've found a working solution. The case The case I'll create is that I've got a lot of persons and a knows person get 0, 1 or multiple languages. The ...
4
votes
2answers
6k views

Handing “Others” option in dropdown in ASP.Net MVC 5

Business Logic I have a company referral form, and in that form I have dropdown to select from a company list. But when a company is not found in the dropdown, the user can select option as "others", ...
3
votes
1answer
9k views

Display a dropdown based on another dropdown change

I have a dropdown and when that dropdown changes I want to display/render another dropdown. Can someone help me improve it? So, a person requests for getting referred in a company for a job. When ...
6
votes
2answers
6k views

“Forgot password” functionality

I want to implement the "forgot password" functionality in Asp.Net MVC 5. Here is the code flow: Take user email ID Let the user enter the token received in his email inbox If the token matches then ...
3
votes
2answers
153 views

Submitting a form

I am using ASP.NET core entity framework. I am using an input submit button to call a method that has a variable attached to it. I am wondering if there is a way to improve my code. Here is my ...
2
votes
1answer
57 views

Website to Track Project's Progress

This ASP.NET MVC website is for my professor to track my progress on my Checkers app. This is the first time I have build an ASP.NET website entirely on my own, and I would like a review to make sure ...
3
votes
2answers
132 views

User can add and delete customers

I am using asp.net core entitiy framework. The page displays the customers. The user can add new customers or delete existing ones. I am looking for ways to improve my code. Here is my cshtml page ...
1
vote
1answer
507 views

Update data in partial view

I have partial view which update data on server. Partial view contains list of configurations (can be check box or text box depends on type). This code is working, and I would like to know how to ...
-1
votes
1answer
73 views

Should you declare variables to make Model property names shorter? [closed]

Let's say the model for a razor view has the following name: Model.Receipt and there are a couple of places where you do ...
1
vote
0answers
249 views

Mail service implementation using Razor engine a MailMessage

This is a very basic Mailer service that I put together after finding out that MVC Mailer doesn't play nice with MVC 5. ...
1
vote
1answer
867 views

Bundling JavaScript resources for an MVC app

This is my first MVC app. I'm looking for best practice feedback on how to best bundle the files that I need, the order to bundle them, the placement of the @render ...
9
votes
1answer
50k views

MVC binding list of values to checkboxlist in an efficient way

I have this code which generates and shows list of selectable items that user can post to controller in order to save into database. Model looks like this: ...
4
votes
1answer
105 views

Joining tables with EF

Here is my database: Here is my viewModel: ...
5
votes
2answers
15k views

A set of Razor HTML helpers for disabling elements

I am developing a huge form with a lot of elements in it. The purpose of this form is editing one domain entity. Now, I finished developing the whole form and it just shows the bunch of text boxes, ...
2
votes
0answers
220 views

Umbraco Macro-Script to grab Contour Form and Node Properties

When it comes to the Umbraco CMS, there are components called "Macro-Scripts" which are essentially a Razor View (.cshtml). They allow you to code a bunch of C# and ...
4
votes
2answers
2k views

Displaying separated multi-line text fields

The following code grabs the HTML-encoded, multi-line content of a text field. It then splits the content on line breaks, and finally displays it with commas as separators. I would like to have this ...
1
vote
1answer
575 views

Formatting MVC 5 Razor link as a string

MVC 5 doesn't seem to like JavaScript that much. I am creating link in JavaScript to a success method in my Ajax call. Razor: ...
4
votes
1answer
9k views

Listing users in Azure Active Directory

The code below is the Index Action from a User Controllers. Basically this code returns a list of users from Azure Active Directory using Azure Authentication Library (ADAL). However I need to show ...
5
votes
1answer
508 views

Redirecting a user

When the user clicks the first button ('Back to List' button), I redirect the user to the Employee List page. Can you please review this and suggest if there is any better way of achieving the same? <...
6
votes
3answers
3k views

Monkeying around with Survey Monkey and Asp.Net Mvc

Intro I've been a desktop dev for a long time now, and have never really had to monkey with web development until very recently. I have a need to do some custom integration with Survey Monkey's Api ...
1
vote
3answers
2k views

Partial view for frequently used drop down lists

I have one input that is needed in many forms, so I created a partial view for that. In the partial view I query the database and generate a drop down list. I just want to make sure, this is the best ...
3
votes
1answer
283 views

Razor view to render simple scaffolding for complex type

After several attempts to follow my intuition that this code can be refactored to something more DRY, I keep hitting road blocks. Hoping someone can see a refactor that might get me going in a nicer ...
1
vote
4answers
8k views

Partial page refresh Ajax call on button click

...
4
votes
1answer
93 views

Generate N pairs of checkboxes and N textboxes

I've written a piece of code, where a pair of checkboxes and a textbox are generated N amount of times. Depending on what's in the DB, the checkbox/textbox may have a default value or are left empty. ...
2
votes
1answer
44 views

Disabling buttons on forms

I have 5 different forms where I am disabling the submit button when a valid form is submitted so the form can only be submitted once. I am using a hidden field on each form to get the form Id. ...
4
votes
3answers
154 views

Make huge view in C# readable and maintanable

I have an application that is using MVC5 with C# and Razor Engine. This view displays a huge table: ...
3
votes
1answer
1k views

Quiz form website

I'm trying to get a good grasp on ASP.Net MVC, Razor and RadioButtons, so I tried to make a quiz to test my skills. I implemented a working quiz form in the following way in Razor (not posting the ...
4
votes
2answers
8k views

Is it “legit” to use a Linq query in a razor view?

I have a Linq query in my razor view like below. Its just getting contacts that belong in the group. ...
3
votes
1answer
165 views

Replacing div if there is any validation error connected with the div value

I have an input group: ...
10
votes
2answers
4k views

Feature-based authorization

Feature-based authorization It seems to me that if you rely on roles to authorize a web application it makes it very difficult to render UI or code based on a set of features. This means that each ...
7
votes
3answers
757 views

Ternary extension method

I created the following HtmlHelper extension method for my Asp.Net MVC Razor views because the ternary syntax sucks when you need to use it intermixed with markup. Is there a better way to write this ...
5
votes
2answers
3k views

Convert looping statement to linq mode

I have a model object class like this ...
5
votes
1answer
164 views

Displaying alert from an action

This code works great, but I think it can be reduced. ...
1
vote
1answer
203 views

Passing a true/false value to a model used in a controller

This passes the value of true/false to model which I can use in my controller. How can this be cleaned up? ...
14
votes
0answers
1k views

PowerShell module for formatting objects using Razor

I managed to get something up and running, but I've no idea whether there are better ways to do this. I've spent all morning trying to figure out the best way to use parameters (allowing objects from ...