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
-
2
votes1
answer203
viewsChoose which items of a enumerator appear in an Enumdropdownlistfor
There is how to select only a few items from the enumerator to send to a EnumDropDownListFor ? Ex: public enum Documento { CPF = 1, RG = 2, CNPJ= 3 NASCIMENTO = 4 } And I would like that in a…
-
2
votes1
answer236
viewsHow to use in @Html.Checkbox?
I have the following code: @{ var st = //(minha lógica q retorna bool); } @Html.CheckBox("MeuNome",st,new { id = "MeuID", value = "MeuValor" }) I can’t use the variable st in the second parameter of…
-
2
votes1
answer133
viewsTAB key navigate only in MODAL
Good morning Galera, I need to make the TAB key navigate only in modal, an example is Twitter that when the Modal message is open or any other, we can not navigate the screen behind through the TAB,…
-
2
votes2
answers3862
viewsDisplay dynamic images using Razor
Hello, I’m having trouble displaying dynamic images using Razor syntax in an Asp.net MVC 5 project. I have the image path stored in a column in the database, named Imagery. Below the code of my…
-
2
votes1
answer163
viewsManipulating Radiobutton to have no value in any field
I need your help: I have two radiobutton, and I wanted to turn them into checkbox, only I can not change the type for checkbox, on this radio I could make to select and to remove if you want. Could…
-
2
votes2
answers3063
viewsPass values from a form to a method in the Model and return the result to another textbox in the Form
I have a very simple form with 3 textbox and a button. I would like to take the value of the first two textbox by clicking the button and passing to a method present in my model and after that…
-
2
votes3
answers10463
viewsHow to use @Html.Radiobutton, how to send the selected option to the controller?
I’m trying to send the selected option of Radiobutton to the controller, I’ve tried to do several ways, I’ve searched several places and I don’t have a solution. Thanks Index @model…
-
2
votes1
answer279
viewsHow to assign a default date value to a Textboxfor?
I own the following Textboxfor @Html.TextBoxFor(model => model.data, "{0:dd/MM/yyyy}", new { @class = "form-control", @alt = "date", @placeholder = DateTime.Now.Date.ToString("dd/MM/yyyy"),…
-
2
votes2
answers1688
viewsDisplay control in Partial View conditionally
I need a control of a Partial View is displayed according to one condition. For some views a button would appear for others not and this would be set through a parameter in the call of Partial View.…
-
2
votes1
answer734
viewsMVC - Creating a typed model as a generic list
I would like to create a typed model being a list of the type T. Utilizing: Razor from ASP.NET MVC 5 For example: My model in the cshtml will look like this: @model List<T> @foreach (var item…
-
2
votes1
answer124
viewsHow to apply mask in these cases?
How to put mask on item @item.CPFCNPJDevedor? @foreach (var item in Model.Result) { <tr> @if (Permissoes.Where(x => x.Acao == "EditChassiCrvGravame" || x.Acao == "VisualizarChassi").Any())…
-
2
votes1
answer640
views@Html.Actionlink submitting Post MVC form
@using (Html.BeginForm("MinhaAction", "MeuController", FormMethod.Post )) { <div> <table> <thead> <tr> <th>Empresa</th> <th>Cliente</th>…
-
2
votes2
answers2426
viewsDisplaynamefor and Displayfor
Studying about ASP.NET MVC, I came across the following lines of code: @Html.DisplayNameFor(model => model.Title) @Html.DisplayFor(model => model.Title) I can’t understand the difference…
-
2
votes1
answer45
viewsSystem.Invalidoperationexception Database Opening Error?
I am using webMatrix, to develop an example in Jquerymobile, I am having the following error @{ Layout="~/shared/_Layout.cshtml"; Page.Title = "Home"; Page.Header = "Categorias"; var db =…
-
2
votes2
answers576
views@If inside a <body> tag
How to put a condition if within a tag <body>? While trying to make: @if (Request.Path.Substring(Request.Path.LastIndexOf("/") + 1).ToLower() == "default") { <body class="home" } else {…
-
2
votes2
answers1229
viewsScroll through a table (grid) Razor MVC
I have a table that is filled by a Model in HTML Razor in a partialView, a field of that table I left as editable using the @Html.TextBoxFor. After the user edit this field need to update in DB, but…
-
2
votes1
answer31
viewsConvert value to display in table - mvc Asp-net.core
I have a table that brings me a value in int and I need to convert this value to time, as I can perform this procedure, in case I would need to create a function to show me the correct value.…
-
2
votes1
answer2950
viewsDropdown List from a table in the Database
I’m developing in Asp.net-mvc and I have the following problem: I need to create a dropdown list that displays the name of the instructors registered in the Database. CRUD is already working…
-
2
votes1
answer209
viewsAdding selected columns together
I have the following scenario: A table created in the Razor with several columns, where each row has a checkbox in place different from each other, and would like to do the checkbox sum clicked by…
-
2
votes1
answer651
viewsChild actions are not allowed to perform redirect actions. MVC 5
On my homepage, there’s a shortcut button that opens a modal, and inside that modal is a partialView which points to a action within another controller. Until then quiet. <div class="modal fade"…
-
2
votes2
answers338
viewsHow to put html id tag with variable name using Razor
Hey, you guys. A very silly doubt, but it’s giving me a lot of headache... I have this snippet of html code using Razor in Asp net mvc, I want to merge the id of this snippet, like, "name + code…
-
2
votes1
answer3137
viewsCreate a dropdownlist and get the selected id Asp.net MVC
I need to create a Dropdownlist at runtime with 2 choices. With this, I need to do a check taking the selected record and then accessing such method. This after clicking on a ActionLink. How to set…
-
2
votes2
answers174
viewsFormatting values per Razor pages
I’m having problems formatting a variable through the Razor pages in C#. Let’s say that a variable called value receives the number 9.5723 (real nine and 57 cents), I need all decimals above 2 are…
-
2
votes1
answer957
viewsForm using Begincollectionitem gets null viewModel in foreach
I want to make a form where I can register several addresses and phones to a single person, and I want to be able to do this when I’m registering the person. Based on the answers to my other…
-
2
votes1
answer81
viewsForm with two destinations
I have the following form: @using (Ajax.BeginForm("minhaAction", "meuController", new AjaxOptions() { HttpMethod = "POST", OnFailure = "alert('Erro!')", OnSuccess = "TrabalharResultado" }, new { id…
-
2
votes2
answers817
viewsI can’t implement a @Foreach on MVC
I’m a beginner in ASP.NET MVC development and I need some help. I’m having trouble creating a Foreach. Follow my code below. @foreach (var item in Model.Fornecedores) { <tr> <td>…
-
2
votes1
answer194
viewsModal pagination using Url.Action
I have a modal of products, in the controller page has a get function to complete it when opening, and a post for filters and pagination. My problem is that paging is done by Url.Action("Index", new…
-
2
votes1
answer465
viewsHow to play a stream streaming mms on ASP NET?
I use the Microsoft Encoder to transmit a video via protocol MMS. The video is streamed by streaming. It is the footage of an event being streamed synchronously to the network (for the time being…
-
2
votes1
answer92
viewsHow to insert information from a model that has a Relationship?
I have a listing of Products and this listing has the supplier code, I need to enter the name of the supplier in this listing. My Controller: public ActionResult Index() { IEnumerable<Produto>…
-
2
votes1
answer446
viewsSeparator of thousands
How could you put thousands apart into one textBoxFor()? Example: Value entered in View 1,321 ( The point is for visual ease only) controller would receive the 1321 value to insert into the base. My…
-
2
votes1
answer1537
viewsDoubt with passing Parameter Asp.net MVC
Calling the controller is no longer calling the Actionresult (Solved) I have my view: @model IEnumerable<Generico.Dominio.TB_MENU> @{ ViewBag.Title = "Index"; } @Html.Partial("_navbarInterno")…
-
2
votes1
answer129
viewsDropdownlistfor in a for
I am trying to fill in with the selected value one DropDownList within a for, but it’s not working properly. What happens is that when the Action Index returns the model to a View, values are not…
-
2
votes1
answer437
views@Html.Editorfor Datetime property remove hh:mm:ss
In my model have a field DateTime called Dating, I graduated with Attributes, but when I’m in view is filling in hh:mm:ss I just want the date 29/02/2016. Model [Column("sdt_DataReferencia")]…
-
2
votes1
answer487
viewsHow to create master-detail form using a Viewmodel
I have a viewmodel in my project. Within it I have two entities that are a list of items. I’m doing the data editing logic of these entities that are inside the viewmodel. I have 5 entities in all.…
-
2
votes1
answer925
viewsDate-place on @Html.Editorfor
I have a model property that I will keep DateTime: [DataType(DataType.DateTime)] [DisplayFormat(ApplyFormatInEditMode = false, DataFormatString = "{0:yyyy-MM-ddThh:mm:ssZ}")] public DateTime…
-
2
votes2
answers1172
viewsHow to make a button with Razor and Css
I’m trying to make a button on a particular page. However, my entire project started with the Razor engine, so I would like to know how I can make a button with such engine, I am trying to do so:…
-
2
votes1
answer133
viewsPut variables in the URL in MVC to use with JS
I have a search page that will fetch the results using ajax. Do the searches you do, the URL is always the same, because the page does not change. Is there any way I can change the URL also when I…
-
2
votes1
answer68
viewsHow to create a View for screens with width less than X
I have a site MVC4, which is not responsive, and change all its implementation just to make it responsive does not seem to me at all productive, because it is a site where worked many people and…
-
2
votes2
answers1884
viewsWhat are model and model variables for in a View?
What are variables for @model and Model in a view? In my view I use it at the beginning of the code: @using Html5DataList.Models @model List<Estabelecimento> And to access the data, I use it…
-
2
votes2
answers262
viewsDropdownlistfor selected values do not persist
I am using Asp.net C# with mvc 4 and in my View I have a Dropdownlistfor, with a class I used of bootstrap-multiselect, as in the image: And the code in the view: @Html.DropDownListFor(m =>…
-
2
votes1
answer1353
viewsC# Decimal field accept value equal to or greater than 0 in validation
I’m having trouble validating my type fields decimal using Razor, when I try to enter 0 in the field it gives the following error message. The field XXXX must be a number. Follow down my class and…
-
2
votes1
answer1186
viewsMultiple select list with items already selected using Razor
I’m using Razor to generate a SelectList thus: @Html.DropDownList("StatusImovel", new SelectList(ViewBag.ListaStatus, "IdStatus", "Descricao"), new { @hidden = "hidden", @multiple = "multiple",…
-
2
votes1
answer198
viewsText-Align of a Label only
On a ". cshtml" web page I have several Abels declaring the class horizontal form and the class control-label. By default, these classes align right in my project, ie.. implement the property…
-
2
votes2
answers202
viewsModel error on Razor page
I have this cshtml @model IEnumerable<TreinamentoCrud.Models.Cidade> @{ ViewBag.Title = "Index"; } <h2>Index</h2> <p> @Html.ActionLink("Create New", "Create") </p>…
-
2
votes1
answer1035
viewsSelect Multiple with jQuery Chosen
I have a class Client, and a class System Man client may have more than one system, and a system, may have more than one client. I have a select Multiple capo, in my edit view, which loads the…
-
2
votes1
answer92
viewsAdd HTML Properties to an input via Razor
When I create a field input-type-text Via Razor, I do something like this: @Html.TextBox("nomeTxt", null, new { @class = "form-control", @placeholder = "Exemplo de placeholder", @type = "text" })…
-
1
votes2
answers2408
viewsHow to render two typed Views on an Index()?
I’m trying to render two views created with the scaffolding, one is for the Create and another is for the List. The idea is to join in index the following: @model BraveryBranded.ASP.Models.News @{…
-
1
votes1
answer1497
viewsSystem.Web.Mvc.Web missing, what can I do?
After a few updates, my helpers started giving problems, for example, if I were to use the @Html.TexBoxFor, Razor would never recognize. After doing a lot of research, I was asked to use the @using…
-
1
votes1
answer873
viewsChange font size using @Html.Label
How do I assign a font size and colors using @Html.Label? I know if I use htmlAttributes I can use: @class = ... i get via css. But I wish I could do it without using CSS. It’s like?…
-
1
votes1
answer502
viewsHow to add an amount sent from an onclick to Ajax date?
I have a table in HTML and in a table column there is a link that opens a Modal. In this modal I register approvals and show who approved and the date of approval (More than one person can approve,…