razor

Telerik MVC Grid: How to use DropDownList in a column?

*爱你&永不变心* 提交于 2019-12-19 04:14:41
问题 I have a Telerik MVC grid, in an MVC 3 application with Razor, which is being Ajax-bound. I am now trying to add a drop list column to it, so that users can use it in edit mode, but can't figure out how. The grid displays a list of Products, and I want the drop list to contain a collection of ProductCategories, to which the Product can be associated. I've been at this for hours now and I'm out of ideas. I really hope someone here can help :) I have been referencing a Telerik demo, which is

Set a RadioButtonFor() checked by default within a Foreach loop

二次信任 提交于 2019-12-19 04:01:34
问题 I have a weird behavior using @Html.RadioButtonFor Extension Method. I am using a foreach loop to create a list of RadioButton and By ternary operator. I am trying to set the one who respect the condition to checked but It is always the last who is checked. I searched similars question but I am not sure to have found something. And I don't want to create/use a custom RadioButtonList . Here my code in my View : @foreach (var item in Model.Entities) { <div> @Html.RadioButtonFor(m => item

Access MVC3 Model properties from Javascript in the View

久未见 提交于 2019-12-19 03:46:16
问题 I am trying to build out a google chart in an mvc app. Here is a snippet of google Chart javascript function drawChart() { var data = new google.visualization.DataTable(); data.addColumn('string', 'Task'); data.addColumn('number', 'Hours per Day'); data.addRows([ ['Work', 11], ['Eat', 2], ['Commute', 2], ['Watch TV', 2], ['Sleep', 7] ]); } what I would like to do is essentially replace the data.addRows line above with a for loop iterating through the items in my model. I can iterate just fine

Visual Studio 2012 asp net mvc 3 project razor view

烈酒焚心 提交于 2019-12-19 03:44:09
问题 I have problem with intellisense in my asp net mvc 3 project in new visual studio 2012 RC. If I open VS2010 SP1 asp net mvc project in VS2012, cshtml view like this one : @model Intranet.Web.ViewModels.Login.LoginVM @{ Model. // dynamic expression - This operation will be resolved at runtime } My configuration : Windows 8 x86(x64 fail too), VS 2012 and 2010SP1 installed. So, is this bug? Thanks 回答1: Add <add key="webpages:Version" value="1.0" /> to <appSettings> in Web.config. Otherwise,

MVC3 - Only first row link works well with Jquery Modal Dialog

那年仲夏 提交于 2019-12-19 03:38:12
问题 Working with MVC3, Razor, Jquery, Javascript. The below code loops through and displays a table structure with fields and a link. The link on each row, triggers a Jquery Modal Dialog that displays a partial view page as a pop up. But the pop up dialog works only for the first row... the link from second row and down open the page as a full blown web page and not a pop up modal dialog. How to fix this..thanks for any help. @foreach (var item in Model) { <tr> <td> @Html.DisplayFor(modelItem =>

Binding conflict between a property named Title in my Model and View.Title in my View (in MVC)

谁说胖子不能爱 提交于 2019-12-19 02:18:09
问题 My Model contains a property named Title , and in my Create view I set the page title using ViewBag.Title . This creates the following problem: the form generated by Html.Editor will display the text from ViewBag.Title , instead of the model's Title value. The only workaround I have found is first calling Html.Editor , and then setting the View.Title . Does anyone have a better solution? Edit 1: I am using MVC 3. Edit 2: This is my DisplayTemplates/Object.cshtml : @model dynamic @using Iconum

Is it possible to use razor syntax in Javascript files?

别来无恙 提交于 2019-12-19 02:18:09
问题 I'd like to use razor syntax inside my Javascript files. Is this possible without including the javascript inline into the page? 回答1: I found a razor engine RazorJS on nuget that solves @ in js files The owner blog and explanations about the package abilities The Nuget package see more in this question 回答2: The Razor engine only runs against the page, not any included javascript files. You could write a custom parser that will run the view engine against any javascript files before serving

Razor HTML Conditional Output

时光怂恿深爱的人放手 提交于 2019-12-19 02:08:25
问题 I have a list of items I want to output as the contents of a main (the main in not included below). Each Item has 3 attributes: a Section Name, a Label and a Value. Each item is enclosed in a and everytime the Section Name changes I have to open a (and close the previous one, if any). I'm using a Razor view with this code: @foreach (LocalStorageItem lsi in Model) { string fld_name = "f_" + lsi.ItemName; if (lsi.SectionName != sn) { if (sn != "") { Html.Raw("</fieldset>"); } sn = lsi

Dropzone.js inside Modal does not work

独自空忆成欢 提交于 2019-12-19 01:12:32
问题 I'm using dropzone.js to upload files to the server. I included the js and css files and the "drag zone" is within a modal window that opens on the click of a button (the modal includes more elements that are not relevant here) The problem I'm facing is that, inside the modal dialogue the "add file" section does not get triggered. Nothing happens when clicking on it, neither am I able to drag and drop files. I saw a similar problem in another thread, but the solutions provided there didn't

Dropzone.js inside Modal does not work

徘徊边缘 提交于 2019-12-19 01:11:32
问题 I'm using dropzone.js to upload files to the server. I included the js and css files and the "drag zone" is within a modal window that opens on the click of a button (the modal includes more elements that are not relevant here) The problem I'm facing is that, inside the modal dialogue the "add file" section does not get triggered. Nothing happens when clicking on it, neither am I able to drag and drop files. I saw a similar problem in another thread, but the solutions provided there didn't