Questions tagged [razor]

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

razor
Filter by
Sorted by
Tagged with
1 vote
2 answers
2k views

How do I encode the user input for an <input type= "text"> in razor view?

I have the following input tag to implement an auto complete search: <input type="text" name="q" data-autocomplete-source="@Url.Action("QuickSearch", "User")" /> Will the user input be ...
John John's user avatar
1 vote
2 answers
1k views

getting dropdown's text in Post action method

I have a Razor view in my asp.net MVC3 application with a dropdownlist like this: @Html.DropDownListFor(model => model.Account.AccountType, new SelectList(Model.AccountTypes, "AccountTypeCode", "...
DotnetSparrow's user avatar
1 vote
1 answer
4k views

Telerik MVC Grid (Razor) - HeaderTemplate

I am trying to have image column headers in my grid. They sort of look like one of those cartoon balloons. But it is a 3 part image: Left (fixed) Middle (expands to fit) Right (fixed) Using the ...
Ed DeGagne's user avatar
  • 3,259
1 vote
1 answer
2k views

jqGrid with MVC3 url action not firing

I was trying to follow the most recently updated tutorial for jqgrid and MVC3. I have this script: myGrid.jqGrid({ url: '<%= Url.Action("GridData") %>', ...
Doug S.'s user avatar
  • 682
1 vote
1 answer
81 views

Razor making the build time longer

I have just switched from old-style to razor. Since this point the compile time has become much slower, is there any thing I can do? Thanks.
SexyMF's user avatar
  • 10.9k
0 votes
2 answers
217 views

how to get page to a specific part of page?

I'm trying to create a page where a user clicks on a link on the left and is taking to a specific section on the page. Here is example. I've added as much of the code I'm using as I can.
Beginner's user avatar
  • 29k
3 votes
2 answers
4k views

Razor syntax: Trouble figuring out nested statements and variable scope

I'm having trouble figuring out Razor syntax and how variable scope works. I'm new to C# in general as well as Razor syntax. Here is some code I created parallel what I'm looking to do, just a bit ...
TMC's user avatar
  • 8,116
1 vote
2 answers
242 views

Suggest me whether to study Razor or basic C# for a developer fluent in HTML and CSS

I'm fluent in HTML and CSS and decided to start learning asp.net. I understand the concept of programming and have started to learn to basics of c#; I know that the razor view engine is based on the c#...
Bankrobber's user avatar
6 votes
2 answers
12k views

MVC3 + How to get the current logged on user's user name

I am new to MVC and actually new to web development all together. I have about 7 years of development experience but in services, database, object models, etc.. basically middle-tier and back-end ...
PWS's user avatar
  • 101
0 votes
2 answers
1k views

Overriding EditorFor ID field within nested EditorFor

Hi I am trying to explicitly change the ID and Name and Validate-For fields in my EditorFor outputs. I have the following code: Html.EditorFor(x => ViewBag.NestedFormDatas) The above prefixes ...
Dav-id's user avatar
  • 1
1 vote
3 answers
577 views

Method not found - System.Web.Razor.RazorTemplateEngine.GenerateCode when deploying to azure

I am developing an MVC3 app for azure which is working fine in my local environment, and the azure emulator. However, when I deploy it to azure I get the error 'Method not found: 'System.Web.Razor....
Jason's user avatar
  • 15.9k
0 votes
1 answer
125 views

bind second ddl depending on the first ddl

I have a page where I have a LeagueDDL, a ClubDDL and then a list of players. What I want to achieve is that the user will choose the League, after that the Clubs are bound to the second DDL ...
JMon's user avatar
  • 3,397
-1 votes
1 answer
2k views

Cutom Routing in MVC Razor URlHelper.Action Path Issue

I have Custom routing for my application as shown bellow Application Name is ValidationTest and i do changed my default binding to following . That works fine , But i do have some Actions in ...
Anto Rubin's user avatar
0 votes
1 answer
569 views

Using different layouts in an ASP.NET MVC3 project (Razor)

My ASP.NET MVC3 project consists on the one hand of the Website itself and on the other hand of something like an "Admin control panel". This means I have to use 2 completely different master layouts. ...
alapeno's user avatar
  • 2,774
1 vote
1 answer
3k views

Telerik MVC3 Razor Batch edit Grid with a Client Template issue

I am using a Telerik MVC Batch editable grid with ASP.Net MVC3 Razor views. In addition to having the grid to be editable I am also trying to add a column with an Edit link (ideally a linkable image), ...
sdd's user avatar
  • 153
28 votes
4 answers
33k views

How to render a Razor View to a string in ASP.NET MVC 3?

I've been searching the site a lot, but all I could find were examples on how to render partial controls .ascx, or depended on a controller context. I want a method that enables me to provide just ...
bevacqua's user avatar
  • 48k
1 vote
1 answer
425 views

How to retrieve data with MVC3 Many to Many relationship and EF4.1 Model First?

I'm a very beginner and I want to do something really simple, I guess I missed something but I could not find the answer. I have two tables with many-to-many relationship mapped with EF4.1 public ...
user1204137's user avatar
1 vote
2 answers
464 views

How to convert to asp.net razor syntax from webforms the following?

How can I convert the following statement into razor syntax? OnDocumentReady Method accepts Action as a parameter <% Html.Telerik() .OnDocumentReady(() => { %>$("#searchbox")....
Cheburek's user avatar
  • 2,103
0 votes
1 answer
490 views

MVC 3 dropdown list not getting any values

I have a dropdownlist in an MVC 3 create page, however I am not getting any values when I POST the page. My code is as follows :- View :- @using (Html.BeginForm("Create", "League", FormMethod.Post, ...
JMon's user avatar
  • 3,397
2 votes
1 answer
642 views

51Degree.mobi and Razor

I create a ASP.net MVC 4 project by using Visual Studio 2010 IDE. I want to make sure that my web application could run at Desktop PC as well as Mobile Browsers which is not the same sizes and ...
Frank Myat Thu's user avatar
1 vote
1 answer
2k views

jquery dialog box doesn't work in accordion mvc razor

I am working on razor project where I need to display jquery modal popup. The popup shows up fine when it's not started from the accordion, but once I put it there, the button doesn't show the popup, ...
Laziale's user avatar
  • 8,105
33 votes
3 answers
13k views

Razor view engine automatically applying quotes?

I'm fairly used to razor now, but I can't understand why the following syntax is correct? <li @(active ? "class=active" : "")> @Html.ActionLink(item.Text, item.TargetAction, Model.Controller)...
DanH's user avatar
  • 3,792
2 votes
1 answer
1k views

MVC Razor GUI and Coder Working Together

I would really like to use the MVC and Razor technology for my web application. The problem I am running into is that I am the coder and will be working with a HTML GUI designer. I only see 2 ways ...
user856232's user avatar
  • 1,073
0 votes
1 answer
1k views

jQueryUI popup doesn't work more then once

I am working on mvc project where jQuery is heavily used. In one of the views there us accordion control with multiple (three) views inside. The jQuery popup works fine in the first panel, but once I ...
Laziale's user avatar
  • 8,105
3 votes
1 answer
4k views

Use of expando objects in views?

Edit: Seems numerous people think this is a dumb idea, so I would appreciate an explanation of why it's bad? I was trying to make one partial view that could handle a list of any models to display in ...
SventoryMang's user avatar
  • 10.4k
-4 votes
1 answer
236 views

What's wrong with this Razor code? [closed]

@using System.Configuration @using UI.AuctionService @using UI.Common @using UI.Helpers @model UI.Models.AuctionFrontendListViewModel @{ ViewBag.Title = "Auction List"; } <h2>@Model.Title&...
Sachin Kainth's user avatar
3 votes
2 answers
7k views

Date validation on search input/textbox for a razor view MVC

I would like to add a textbox (date) and button to my report, which filters the data. The below mvc is working, but the input must still be validated (must be a DATE) on client side (and server ...
David Smit's user avatar
2 votes
1 answer
157 views

Present and layout a set of buttons in ASP.NET MVC 3

I am working on a computer support incident management system. Currently, a Review view for an incident contains several incident manipulation buttons, that are "rendered" onto the view with the ...
Maxim V. Pavlov's user avatar
2 votes
2 answers
8k views

Action Image Link on MVC3 Razor using Helper method

How to do it with razor helper method? The answer at question linked below uses extension method. Action Image MVC3 Razor
Ante's user avatar
  • 8,607
9 votes
1 answer
24k views

How do I return List or Collection to Controller from View in MVC 3?

Someone please help me return this list properly from my view. I don't see why I'm returning null for my fieldModelList I try to pass to the controller... Here is my view: @model List<Regions.SOA....
ob1Jakobi's user avatar
2 votes
1 answer
3k views

Ajax.BeginForm refreshes the view instead of updating target id

My view <div id="ValidationSummary"> @Html.Partial("ValidationSummary") </div> @using (Ajax.BeginForm("Index", //<-- Action name "JobDetails", //<-- Controller name ...
Rajesh's user avatar
  • 2,492
1 vote
2 answers
274 views

How would I display a List<Item> so they are grouped by one of the properties?

So I have a List<SearchResult> Results that will return multiple results for a single Category property, when the Item property is different. So for example the results could be: SearchResult[0]....
MetaGuru's user avatar
  • 43.3k
0 votes
1 answer
506 views

Syntax Issue in Razor code using Vb.Net

I'm working with my first MVC3, vb.net project and am having a problem with the follow code @code ' builds standard list of attributes Dim s1 = SharedAttributeBuilder.BuildAttributes(Me) End Code ...
photo_tom's user avatar
  • 7,332
3 votes
2 answers
23k views

How to create tabs view in ASP.NET MVC3 with Razor?

I am developing a web application in ASP.NET MVC3 with C# and Razor. I need to create tabs within my web page, exactly as it is displayed in browsers. I don't know if there is already a template made ...
CiccioMiami's user avatar
  • 8,146
0 votes
1 answer
794 views

cant get values of item in foreach loop

I can't get the values in the view that I sent from the controller. I tried two ways but I can't make them appear in a div. I must show the values in a table or label. Controller: List<string>...
mathel's user avatar
  • 29
1 vote
1 answer
858 views

MVC Razor syntax: @ followed by HTML

I came across this code today and don't really understand it. Please could someone tell me what this means and how to interpret it? I have simplified it but it's basically the @ symbol followed by ...
Bobbler's user avatar
  • 643
0 votes
1 answer
466 views

how can i set atributes to @Html.DropDownList

when iam traying to fill a middle table for example when a student want to add a coourse i have in my view a DropDownList for the seletec student a DropDownList for all the course and a DropDownList ...
Diego_DX's user avatar
  • 1,071
0 votes
3 answers
1k views

How to choose a CSS file based on a session value in ASP.net MVC

I'm a bit new to ASP.net MVC 3. I have to CSS files: "red.css" and "blue.css". I would like to code my web application so that whenever Session["color"]=="red", the browser will use red.css and ...
Vivian River's user avatar
  • 31.8k
3 votes
3 answers
2k views

remove selection from select box with jquery

I have a select box, from which I want to remove selected choice with jquery. Please advise me how I can make this working: this is the code for the markup: @foreach (var item in Model.Names) ...
Laziale's user avatar
  • 8,105
0 votes
1 answer
106 views

How to Handle Mutiple Model Bound Forms

I am buiding a UI screen for editing the details of an Ecommerce Order. The model for my view (OrderModel) has everything I need (in properties that are also ViewModels), but the UI isn't designed to ...
ctorx's user avatar
  • 6,881
2 votes
1 answer
147 views

User of Razor on an MVC 2 application

I am new to MVC so I am asking this question, I have visual studio 2010 version 4.0.30319 SP1 Rel already installed and currently we are using MVC2 . I have been asked to you MVC3 razor view engine. ...
user1005310's user avatar
8 votes
5 answers
40k views

Razor View dynamic table rows

I want have a table in my view that is going to put 3 elements from my Model in each row. So the way I was going to do this is to loop through the model and inside of the foreach loop do a check on a ...
esastincy's user avatar
  • 1,627
1 vote
1 answer
3k views

MVC3 WebGrid header alignment

WebGrid (Razor) How can the headers alignment be set? I need to be able to change the alignment for each column (could be different) It seems to be a all or nothing deal nor does it seem to take ...
user1197783's user avatar
0 votes
1 answer
3k views

How to use NodeTypeAlias within Umbraco 5

Getting error 'Umbraco.Cms.Web.BendyContentList' does not contain a definition for 'Children' While trying to use @inherits RenderViewPage @using System.Web.Mvc.Html @using Umbraco.Cms.Web; @using ...
Christopher Marshall's user avatar
28 votes
5 answers
21k views

Razor view engine for ExpressJS [closed]

I've been toying around with NodeJS, ExpressJS etc, and would really like to be able to have a template engine closer to ASP.Net MVC's Razor engine for node (jshtml). I'm curious if anyone is ...
Tracker1's user avatar
  • 19.2k
25 votes
4 answers
19k views

Invalid anonymous type member declarator. Anonymous type members must be declared with a member assignment, simple name or member access

I'm trying to add additional attribute data-icon to my Action Link, but I'm getting the error below: Invalid anonymous type member declarator. Anonymous type members must be declared with a ...
Eugene's user avatar
  • 1,057
2 votes
2 answers
661 views

Simple MVC Razor rendering view issue

I am learning MVC with Razor and have a simple question (I think). I am having trouble displaying the contents of a model in the view and am not sure why. My view is a .cshtml page. I am passing a ...
Ben Cameron's user avatar
  • 4,375
2 votes
2 answers
1k views

MVC3 Checkbox value won't clear

I have a fairly straightforward razor view which needs to be used for a questionnaire, which is used repeatedly until it runs out questions. Checkbox is used for select answers, the problem is when I ...
Low Flying Pelican's user avatar
1 vote
3 answers
3k views

asp.net mvc jquery Ajax partial page update issue

I am having a problem of a partial page update on Asp.net mvc 3 razor that I cannot get through I have this _LogOn partial view which has 2 text boxes Email and Password and a button connexion for ...
dtjmsy's user avatar
  • 2,692
2 votes
2 answers
864 views

Asp.Net Mvc HtmlHelper testing VeiwContext.Writer.WriteLine

I have a HtmlHelper which is used to output some accordion style functionality. This helper is going to be used extensively throughout the site. The code used to create this functionality makes ...
user avatar

1
599 600
601
602 603
666