Most voted "razor" questions
With ASP.NET Razor we have the possibility to insert the application logic directly into the project view layer, for example, it is possible to insert the Razor syntax along with the HTML codes within the same page
Learn more…370 questions
Sort by count of
-
37
votes9
answers34793
viewsInput type="password" with password display eye
I need to put a <input type="password"> with that eye of the reveal password, but it has to work as follows: User clicks on the eye and when dropping hides the characters again. Follow an…
-
18
votes3
answers1166
viewsWrite Timespan in full
I want to write a static class (can be Extension) to represent the value of a structure TimeSpan in full, in Portuguese. The idea is to always compare the current date (Datetime.Now) with the date…
-
16
votes1
answer1856
viewsASP.NET MVC - Attribute you write in a View
I need to write a Attribute write a mask validation in the View. Given for example a zip code field, I would like it to mark a Property in the Model with a [CEP], be written in View the following:…
-
15
votes2
answers2432
viewsHow to create a Date list with a specific day
I am working on ASP with MVC 4, and I hold create a list of dates from the data entered by the user. For example, the user inserts the day of the month in which a certain occurrence will be made. It…
-
12
votes1
answer6870
viewsDate problem with globalize.js and jquery.validation.globalize.js. How to resolve?
I’m having problems with the date fields of my application. Follow this answer that seemed more appropriate, Datetime field error message, I configured my ASP.NET MVC application as follows: I…
-
8
votes2
answers323
viewsWhat is the @ in a view and controller for?
I program in PHP and I’m starting to learn how to program in C# ASP.Net MVC, but I’m having some questions: What is the purpose of @ (arroba) both in controller how much in the view ? What are these…
-
8
votes2
answers695
viewsWhat is ASP.NET Core Blazor?
Looking at the list of novelties found in Visual Studio, I came across something talking about ASP.NET Core Blazor, and apparently there’s almost nothing talking about, I found very little material,…
-
8
votes2
answers1697
viewsControl view component visibility in the ASP.NET MVC 5 controller
I am refactoring a project in ASP.NET MVC 5, implementing some good practices and researching, it was mentioned that the use of if na view(Razor) is not the best practice, only that I use it to show…
-
7
votes1
answer792
viewsHow to export an HTML/C#(Razor) page that contains SVG elements to PDF?
I am currently working with Highcharts, a javascript library that generates graphics. It has an export component, but only exports the chart itself, still need to assemble the PDF layout. For the…
-
7
votes4
answers1531
viewsList all Roles in Checkbox and mark the roles that the User has
I am creating an Asp.net MVC 4 User Management System with two Simple Tables. Users and Roles. I can create users by selecting the roles they will own. At the time of Edit I’m trying to List all the…
-
7
votes2
answers1076
viewsHow to put a @ inside {} in MVC
While doing a MVC5 page with Razor, I went to put the following code {--conteúdo da @ RenderBody() etc, etc } Generated an error because the @ is inside keys ERROR: Server Error in '/' Application.…
-
7
votes2
answers9136
viewsCreate static Selectlist and pass a selected item to the View
I’m having a question about how to send my selectList "status" to my View EditarUsuario. I created my list with the following items: var list = new SelectList(new[] { new{ID="2",Name="Selecione"},…
-
6
votes2
answers874
viewsHide different options (actions) for different user profiles
I am in a project where I have 3 different levels of profiles: Administrator, Professor and Coordinator. I already have the login module, registration and such. What happens is that I wanted for…
c# asp.net-mvc asp.net-mvc-5 razor visual-studio-2013asked 10 years, 6 months ago Érik Thiago 2,338 -
6
votes2
answers2534
viewsRendering Partials in ASP.NET MVC
I’m having a problem in my application where I wanted to use partial to render one page inside another. That is, one controller within another. Only, what happens is the partial does not render at…
-
6
votes3
answers1183
viewsHow to Dropdown ASP NET MVC
I have a DTO class [Serializable] public class PerfilDTO { public int Codigo { get; set; } public string Descricao { get; set; } public SituacaoEnum Situacao { get; set; } public…
-
6
votes1
answer5794
viewsHow to use MVC 4 session with C#?
My scenario is as follows. I have an MVC 4 application. In my controller I check the logged in user and password. (I think) I put the user data in a session after the data is checked and correct. My…
-
6
votes1
answer671
viewsError after performing an action redirect to a page
I believe I am going wrong the code below, it should after saving the Client and redirect to Client/Index page, but after saving is on the same page, using Debug it passes in Client/Index(Action and…
-
6
votes2
answers3494
viewsASP NET MVC Include Url Parameter on all pages
I have an ASP NET MVC application that is multi-client and multi-user, IE, it is prepared to be used by multiple customers and each client can have multiple users. Initially the login form has the…
-
6
votes3
answers4902
viewsHow to load a dropdown with a selected value
I have a method to make changes in some data. Among these data, I have a dropdownlist which contains course periods. When I select to change, I need the dropdown comes with the option checked, as it…
-
6
votes2
answers3207
viewsWhat are the differences between ASP.NET MVC and ASP.NET Razor Pages?
What are the differences and limitations between ASP.NET MVC and ASP.NET Razor Pages? I was very curious, because apparently the Razor Pages use the MVC standard, but without the need to use a…
-
6
votes1
answer2324
viewsValidate maximum size of an attachment
Good afternoon, you guys, I need to validate the maximum size of an attachment but my code is not working, can help me? Follow the code below: HTML: @using (Html.BeginForm("AdicionarAnexo", "Turma",…
-
6
votes1
answer69
viewsDifferent color layout in Textbox (Safari and Chrome)
Safari is fading colors inside that are not @Html.Comboboxfor, as I do not fade into the textbox? I’m using CSS and Jquery, Follow the photo Select does not fade in Safari: @Html.DropDownListFor(m…
-
6
votes1
answer5562
viewsDisplaying message in a view through the C# MVC Controller
looking for a solution I found a way in the link Controller message to view But my problem is that nothing is shown. I don’t know if it’s because I don’t have an action in the View but the message…
-
5
votes3
answers2113
viewsApplication that does not need to load full page
How can I create an MVC C# with Razor, where I have a Layout and then just update the central content and not the page as a whole. I read some places to use AJAX another to use PartialView. But what…
-
5
votes1
answer496
viewsChanges to the database with Asp.net MVC 5
I am starting some independent projects using Asp.net MVC 5 with Entity Framework, and more learning from the technology. And at the moment a great doubt arose. I used the code generated through a…
-
5
votes1
answer1220
viewsSend "@Html.Beginform" to another area controller. Asp.Net
I own a controller in a Area calling for "LoginProfessional", with the actions Index, Logon, Logoff. I make a RenderPage calling for the Index in Area root of the project, but when I click on the…
-
5
votes1
answer1567
viewsError using Viewbag in Dropdownlistfor ASP NET MVC
I have a Dropdown that lists the categories of my system, but when I submit the form without choosing a category, it gives a server error saying that the Value cannot be null. I put a validation…
-
5
votes2
answers676
viewsHTML element inside an Actionlink
Hi, I was wondering if it is possible to create an HTML element inside a ActionLink, for example: To create a link in a menu with ActionLink: @Html.ActionLink("Classificação Financeira", "Index",…
-
5
votes2
answers506
viewsReceive null int in Razor (@Html.Textboxfor)
I have an object Carro and I have a whole-type, annulable property called AnoInspecao. When creating, I can create a car object with the year of null inspection (without typing anything) and persist…
-
5
votes1
answer1108
viewsWhy @Html.Checkboxfor returns "true,false"
In the construction of my View, I have a field of the kind: public bool? RegistoGesOleos { get; set; } Who I represent using Razor as: @Html.CheckBoxFor(model => model.RegistoGesOleos.Value) Now…
-
5
votes1
answer795
viewsGood practice with . NET MVC
I have an ASP.NET MVC application and would like to know what good practices microsoft indicates in the organizational aspect of the solution, using the latest technologies such as ASP.NET Identity.…
-
5
votes2
answers305
viewsOnly constructors without parameters and initializers are supported in LINQ to Entities - Asp.Net MVC
I’m developing an application that manages courses. The student, when entering the registration screen and clicking on the "registration" button, is associated to a course, that is, is enrolled. So…
-
5
votes2
answers1194
viewsWhat is an Engine?
I read an article about Razor. That article says it’s a engine view, but what comes to be a engine? According to the article Razor is a new syntax that works with CSS and HTML to make life easier…
-
5
votes1
answer663
viewsViews do not recognize @model, @Viewbag, @Viewdata
I am using Mono 5.10.1 and Visual Studio Professional for Mac (Version 7.5.4 build 3) Views do not recognize tags like @model, @Viewbag and @Viewdata, either in older projects that were originally…
-
5
votes3
answers11042
viewshow to Fill a Dropdownlistfor
Could someone help me how do I fill one DropDownListFor? Before I was doing it this way: @Html.DropDownList("lstAffiliate", string.Empty); But I saw that it was not recommended, then I decided to do…
-
5
votes1
answer679
viewsDoubt with mvc list editing, using checkbox and editable field
I’ve got a lot of doubt and I barely know where to start, so I’m going to go to college: I have a page cshtml (I’m using Asp.net-mvc). It has a list, assuming that the elements are A, B, C, D, E.…
-
5
votes2
answers296
viewsHow to make a LINQ/lambda and consume it in the view?
I have an object called Radio: public class Radio { public int RadioId { get; set; } public string StreamUrl { get; set; } public bool Ativo { get; set; } public bool Mp3 { get; set; } } I’m doing a…
-
5
votes2
answers585
viewsHow to change Checkbox with Dropdownlist onChange in ASP.NET MVC Table?
I am developing a site with ASP.NET MVC and Razor, I have in one of my pages a table with some columns. I have in this table a State column whose has a Checkbox and another column containing a…
-
5
votes2
answers650
viewsReference class Syntax Razor C#
I have a class where I have saved a configuration key being key and value, but I need to take the value of this key and move to my page cshtml. I’m having a hard time with this. I have already…
-
4
votes3
answers1154
viewsHow to verify if there is a specific value (string) in a list in C#?
I am trying to mount a select Multiple input and leave marked the options that are already present in a certain list. I’m a beginner in C# so the logic of what I need would be more or less this:…
-
4
votes2
answers1514
viewsView Razor to PDF
I need to convert Views of my MVC 5 application to C# using Razor to PDF. I already searched, and the free tools depend on iTextSharp, which I searched for has a different marking. But I need to…
-
4
votes1
answer495
viewsWhat are the positives of using Aspx View Engine instead of Razor?
When researching about ASP.Net MVC, I have always found all the examples of views with Razor (I don’t remember exactly if I saw any in aspx) and in the past I remember that it was possible to select…
-
4
votes1
answer446
viewsHow to internationalize Enum values?
I have the following code in Model: public enum Lista { [Display(Name = "Lista_regular", ResourceType = typeof(Mensagem))] Regular = 0, [Display(Name = "Lista_irregular", ResourceType =…
-
4
votes1
answer357
viewsHide a column from a Webgrid
Good afternoon. I have a Webgrid and would like to leave an invisible column. How could I do that? this is the grid: @{ Layout = null; WebGrid grid = new WebGrid(Model); } @grid.GetHtml(columns: new…
-
4
votes1
answer188
viewsPartial does not render
I have a problem with my application. What happens is that I am not able to render a partial in another view. Here the partial code: @model CEF01.Models.Ocorrencia @using…
-
4
votes1
answer2820
viewsRender pages within _Layout.cshtml of other types. Asp.Net MVC 4
I’m basically developing a kind of social network, but I’m having some problems rendering pages inside my _Layout.cshtml page. Html <ul class="dropdown-menu"> <li class="header">Você tem…
-
4
votes4
answers14354
viewsLine break in bootstrap
I’m making a form, and I have the following code: <div class="row"> <div class="col-md-6"> @Html.EditorFor(model => model.Nome) </div> <div class="col-md-6">…
-
4
votes1
answer241
viewsHelper for writing Htmlhelpers
I’m trying to write a Htmlhelper and seeing some basic examples I found one with the class TagBuilder that already helping: namespace MyNamespace { public static class MyHeleprs { public static…
-
4
votes1
answer611
viewsDataannotation validating property with Javascript plugin. ASP.NET MVC
I need to validate a field of my model that has a text editor in Javascript. So far so good, because the problem only occurs in the registration that I do not receive in the parameter of the Action…
-
4
votes1
answer851
viewsHow to get the path of a file (Httppostedfilebase)?
I would like to get the path(path) from where my file is coming from. Model: [Required(ErrorMessage = "Selecione o arquivo a ser importado.")] [Display(Name = "Arquivo ")] public HttpPostedFileBase…