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
-
4
votes3
answers63
viewsCharacters " ' " and " f " appear in the textbox, how to correct?
We are using MVC5, I put a @Html.Textboxfor a Jquery function that does not allow the insertion of letters, but whenever the user type the characters " ' " and " f ", they are inserted and deleted…
-
4
votes1
answer617
viewsValidating start date and end date for the same Model attribute
Description of the problem: I need to create a form with an initial date and end date to list sales of a product per period. Let’s take this model as an example: public class Produto { [Display(Name…
-
4
votes2
answers730
viewsASP.NET MVC session
Staff I have a controller where Seto two session keys and that capture those key anywhere in the application. (other controller, or a view). The controller is like this: [HttpGet] public…
-
4
votes1
answer1174
viewsRazor C# list and sublist with List<String> (originally "how to check if an HTML element already exists")
I need to know if an HTML element already exists, in my loop, if it exists I use it, if it doesn’t exist I create a. How would you do it inside a @foreach (var item in Model){ ... } Following the…
-
4
votes1
answer682
viewsSend only object from the list that has changed to the controller
I own a view who lists all my customers. Each customer has 3 checkbox where the user selects them, and sends them to the controller - through the button (Submit) - the data to change. The method is…
-
4
votes2
answers535
viewsHow to access Action in another Controller via Ajax?
I have an Aspnet MVC project structured as follows: Projeto L Areas L Area1 L Controllers L MeuControllerArea1Controller.cs Views Area2 L Controllers L MeuControllerArea2Controller.cs Views L…
-
4
votes1
answer392
viewsWhat is the advantage of using Tag Helpers in ASP.NET Core?
I am studying the ASP.NET Core and came across the tag helpers when I ran the scaffold of a view. I found interesting the new syntax, the code is more readable at some points, however, the inclusion…
-
4
votes1
answer691
viewsHow to recover logged in user name and display in View
I’m trying to develop a page, where after the user login, it is redirected to an index, where I would like to display the user name. I’m using Identity default of ASP.NET MVC. So I thought I’d put…
-
4
votes2
answers353
viewsWhat is the difference between @Url.Content("~/css/bootstrap.css") and only "/css/bootstrap.css"
I am learning to program an application based on MVC4 and Bootstrap. At the beginning of the project I came across a puzzle: In the _Layout.cshtml I had <link href="css/bootstrap.css"…
-
4
votes2
answers638
viewsInsert checkbox dynamically by returning Json does not display Text?
I’m creating a list of Checkbox according to the selection of a Select on the same screen. No event change of select is called via ajax javascript, the method that returns a Json with list(value,…
-
3
votes2
answers985
viewsHow to export an HTML/C#(Razor) page to PDF?
I have some simple tables and need to export them to PDF. I found the library itextsharp, but in the compressed file there are many folders and files and do not know how to add the reference in my…
-
3
votes2
answers330
viewsDisplay layout only when view is not loaded via ajax
In my project, I am developing so that the application works even if the user is with Javascript disabled or unavailable. If Javascript is not available, I load the page normally. If available, I…
-
3
votes2
answers1328
viewsHow to make a user helper logged in to Asp.NET MVC 4?
I need to implement a Helper for logged in user, ie a static class that returns information about the logged in user from context. The idea is to use the information both in Controllers how much in…
-
3
votes1
answer1517
viewsSelect only one Radiobutton with Razor
I have 2 Radio Buttons, and I would like when I mark one, the other to cancel. Follow the image of what is occurring: Code: @Html.RadioButton("teste", "teste", true) Teste…
-
3
votes1
answer622
viewsMaster Page does not appear in the list when I try to associate it to a view
I am using Microsoft Visual Studio 2013 and created a C# ASP.NET MVC 4 project. I created a Master Page in the directory of Views, calling for Modelo.master. Then I created a Controller in the…
-
3
votes2
answers673
viewsCheckboxlistfor with error
Description: Error when compiling a resource needed to fulfill this request. Examine the error-specific details and modify the source code appropriately. Compiler Error Message: CS1061:…
-
3
votes2
answers2764
viewsIF condition inside _Layout.cshtml in MVC
I have two _Shared.cshtml (MVC masterpage type, do not know the name) and both are virtually equal, only the menu left is different. I would like to do only 1 and according to the querystring I will…
-
3
votes3
answers298
viewsHow to use Resources in . js file?
I have a project Asp.Net MVC where I’m wearing Resources, and to use it in my web pages it’s easy! @using projeto.Translations <h3>@Resources.DISPLAY_OLA</h3> The problem is that I have…
-
3
votes2
answers782
viewsJavascript and Asp.net mvc help
In my project I have a field that is the Status of a certain occurrence. That is, if it is pending or solved. I made a javascript function that , by clicking the input field that is in readonly…
-
3
votes3
answers230
viewsSQL Query export for excel
Good, I’m having some difficulties in the result of a query. To fit you is the following, I have a registration application of "unavailability." and I need the following: Every day I have to extract…
-
3
votes1
answer237
viewsVallidationsummary shows no error on screen
I am using Validationsummary in Forms, but these are not being rendered. Is there any known reason for this error? Form example: @using (Html.BeginForm("CadastrarPessoaFisica", "Usuario",…
-
3
votes1
answer45
viewsHow to "escape" the @ in Razor
I am trying to leave @ as string. Here is the code: hint: { mentions: ['Pedro', 'Tiago', 'João', 'Maria'], match: /\B@(\w*)$/, // Problema com @ search: function (keyword, callback) {…
-
3
votes1
answer1102
viewsHow to print text within a @if{ } condition in Asp.Net in cshtml file?
I have the following situation <td> @Html.DisplayFor(modelItem => item.HoraInicial) às @Html.DisplayFor(modelItem => item.HoraFinal) <br /> @Html.DisplayFor(modelItem =>…
-
3
votes2
answers2772
viewsPull data from an input when typing in the field
I need a script that when I type a word into a field, it pulls all the data that is related to that word, like a Facebook example, in the search bar, when we type something it already comes bringing…
-
3
votes2
answers80
viewsInserting special character in view
I have an HTML table where one of your td I need to insert the following information: <td>@item.OrderSend º</td> I would like to insert in this way: <td>@item.OrderSendº</td>…
-
3
votes1
answer2091
viewsMake a button to add properties to a list using Begincollectionitem C#
I have a register of people and need to create a button to add multiple phones and send to my controller, I am using Begincollectionitem, based on my other question Form using Begincollectionitem…
-
3
votes1
answer196
viewsHow to call another class column name in Webgrid MVC
I have this view Listar.cshtml @model IEnumerable<ODM> @{ var idGrid = "grid" + this.ViewBag.IdParameters ?? string.Empty; var grid = new IBM.Web.Helpers.WebGrid(id: idGrid, rowsPerPage:…
-
3
votes1
answer420
viewsError while trying to pass a controller list to view ASP NET MVC
Good morning, everyone, I’m new to development, and I’m having trouble passing a list of a controller query to a view. I did some research and all the ways I found didn’t help much, if anyone can…
-
3
votes1
answer100
viewsUse/Escape @ in CSHTML view
I have a jQuery code on the CSHTML page and I’m having trouble validating the email with a regular expression, because the @ is a Razor command in .NET. How to proceed to resolve this issue? Follows…
-
3
votes1
answer828
viewsGetenumerator error while rendering a View
I did it just as a test: @model Operador.MVC.Models.OperadorModel @{ ViewBag.Title = "Operador"; } <table id="tblOperador" class="table table-hover table-striped" border="1" cellspacing="0"…
-
3
votes2
answers734
viewsError passing values to @Html.Dropdownlist
Man Controller: public ActionResult AssociarDependencia(int codigoMilestone, int codigoAtividade) { try { using (CPMDatabaseEntities db = new CPMDatabaseEntities()) { List<Atividade> lista =…
-
3
votes2
answers126
viewsEdit MVC with Foreign Key
I need to upgrade my editLivros, Next I’ll explain my project. Autores ------- IdAutor Nome Livros -------- IdLivro Nome IdAutor I am registering the Authors and Books correctly, when I am…
-
3
votes1
answer409
viewsDropdown Cascata
My problem is passing values to controller when making an update. I can do the Cascading all right. Follow my code. First DropDown: @Html.DropDownList( "idCanalIndicadoresMassivo",…
-
3
votes3
answers4226
viewsPersist information using Viewbag?
I have my screen login is to show the name is id of the logged in user on another screen, so I can use this information. In my controller: [HttpPost] public ActionResult Index(TB_USUARIO model) {…
-
3
votes2
answers1083
viewsFields in the same line MVC5 Application Bootstrap
I would like a tip on how to put two fields on the same line in Razor, using bootstrap in an ASP.NET MVC5 application. div class="ibox-content"> <form role="form" class="form-inline">…
-
3
votes1
answer46
viewsHow to render 2 typed view from different controllers
How do I render 2 view typed of controllers different? Controller: public ActionResult Index() { Cliente cli = new Cliente(); cli.Nome = "Al Unser"; return View(cli); } Index: @model…
-
3
votes1
answer851
viewsPassing information to a Modal
I have this routine using the C#Razor. It lists my messages : Code: @for (int i = 0; i < 3; i++) { <div class="box-body" style="line-height:15px"> <ul class=" products-list…
-
3
votes2
answers376
viewsSpan inside @Html.Actionlink
I have the following column of a table: <td style="font-size:10%"> <p class="list-group-item-text"> @Html.ActionLink((string)item.cidadenome, "Cidade", "Cidade", new { cidadecod =…
-
3
votes1
answer485
viewsPass the (integer) Return from a Controller method to the View
I have this method in a controller: int GetSpot() { List<CompanyDetail> topCompanies = GetTopCompanies(); CompanyDetail topCompany1 = topCompanies.Where(x => x.Company.TopCompany ==…
-
3
votes2
answers83
viewsASP.NET MVC 5, I can’t bring set when I edit
I have a class of service and in it I have the User responsible for the service, which is a user of the IdentityUser. Remembering that I changed the Identity id from string to "Int", that’s all. I…
-
3
votes0
answers279
viewsError anti-forgery cookie "__Requestverificationtoken" is not present happens only in Internet Explorer
I have a problem I have no idea how to fix. I have an Asp.net mvc app posted on my machine, where I can use all the features (create, Edit, delete) perfectly, whether in Chrome or IE. It turns out…
-
2
votes2
answers1555
viewsCalling action with AJAX, but does not return Alert to view
In the textbox Ticket, at the event onChange() I call AJAX below: $('#Ticket').on('change', function () { var tkt = this.value; $.ajax({ url: '@Url.Action("VerificaTicket", "Oc")', data: { 'tkt':…
-
2
votes3
answers4590
viewsHow to create dropdownlist Razor in . net mvc via ajax?
I would like to dynamically load my dropdownlist without submitting the page! my project is in architecture . net mvc ! @Html.Label("Categoria do Veiculo: ") @Html.DropDownListFor(v =>…
-
2
votes2
answers1040
viewsNull check returns reference error
Model public class Transacao { [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)] public int ID { get; set; } [Required] public DateTime Data { get; set; } [Required] public decimal…
-
2
votes1
answer69
viewsHTML attributes on webgrid lines
It is possible to include the attribute data-id-tarefa="@item.id" within each TR using Webgrid? I can include the attribute by Javascript, but all the Trs return me the same value of the id within…
-
2
votes3
answers1096
viewsPass Viewbag to _Layout
I need to pass a list to my layout where it is used in all my pages, I would like to know how I could do this?
-
2
votes1
answer302
viewsDropdownlist with checkbox
Would anyone know a way to make one DropdownList with checkbox? I have the following Dropdownlist: @Html.DropDownListFor(model => model.CD_AFFILIATE, new SelectList(@ViewBag.list,…
-
2
votes1
answer364
viewsHow to assign Javascript value in Razor?
I have a variable Razor @minhaVarRazor and would like to change its value based on a value obtained from another variable, but which is from Javascript. function setValue(minhaVarJavaScript){…
-
2
votes2
answers321
viewsScript to make a div appear
I have a user registration in my application, when I click register wanted to show a message. This whole treatment I’m already doing and playing the message in my Viewbag.Message. How do I show this…
-
2
votes1
answer1726
viewsHow to pass parameter via button
How do I use text from @Html.TextBox("pesquisa") as parameter in the code below <button id="BtnConsulta" onclick="location.href='@Url.Action("Pesquisa", "Cliente", new { PARAMETRO)'"><i…