asp.net-mvc-3

Public variables in MVC 3 Razor _ViewStart

妖精的绣舞 提交于 2020-05-13 04:32:09
问题 I'm building a site on the new Razor engine that comes with MVC 3 (and loving the new syntax!). However, I am at a loss about using public properties / constants with it. I know that with WebForms we could add a public property in code behind: public string ImageFolder { get; set; } I would like to define important variables in one global place that my views can access, starting with paths to CSS files and images: @{ Layout = "~/Views/Shared/_Layout.cshtml"; var ContentFolder = "~/Content";

Public variables in MVC 3 Razor _ViewStart

China☆狼群 提交于 2020-05-13 04:31:10
问题 I'm building a site on the new Razor engine that comes with MVC 3 (and loving the new syntax!). However, I am at a loss about using public properties / constants with it. I know that with WebForms we could add a public property in code behind: public string ImageFolder { get; set; } I would like to define important variables in one global place that my views can access, starting with paths to CSS files and images: @{ Layout = "~/Views/Shared/_Layout.cshtml"; var ContentFolder = "~/Content";

How to Open .pdf on a new Tab

前提是你 提交于 2020-05-11 04:15:32
问题 The Objective: I have to print a PDF on a new tab after some tasks have finished correctly. Steps: I want to execute a method that should go to the server, take the PDF and open it on a new Tab, I was trying with these but is not working: Controller : Export public ActionResult PrintPdf() { Response.AppendHeader("Content-Disposition", "inline; filename= " + MyClassPdfWriter.GetFileName); return File(MyClassPdfWriter.GetMemoryStream, "application/pdf"); } View : function TasksSucced(){ $.get('

Is it possible to use latin character in comments of t4 template?

拈花ヽ惹草 提交于 2020-04-18 07:06:39
问题 I'm trying to create a portuguese comments in a t4 template of the Add Controller in my project. The comments in t4 template: /// <summary> /// Controller que trata as requisições de pesquisa, inclusão, alteração e exclusão de <#= mvcHost.ControllerName.Replace("Controller", "") #>. /// </summary> The problem is when i add a controller, the comments appear like this: /// <summary> /// Controller que trata as requisi��es de pesquisa, inclus�o, altera��o e exclus�o de Teste. /// </summary> Obs:

Initializing model with ViewModel values

 ̄綄美尐妖づ 提交于 2020-03-23 03:53:34
问题 I want to initialize a new Example model with values from an Example model within the ViewModel. var example = new Example { ExampleViewModel.Example}; The above returns the error: Cannot initialize type 'ManagementOfChange.Models.ChangeRequest' with a collection initializer because it does not implement 'System.Collections.IEnumerable' Does this mean I have to initialize every value individually? e.g: var example = new Example { value1 = ExampleViewModel.value1, value2 = ExampleViewModel

EditorTemplate for List of complex type returns null, while EditorTemplate for its elements works fine

浪尽此生 提交于 2020-03-18 06:18:29
问题 I have a View in which the user can choose any number of Clubs by selecting checkboxex. The Clubs are a property of the main model with type List <ClubModel >. While refactoring I start out with this: @using (Html.BeginForm()) { <fieldset> <legend>Voor Select clubs </legend><br /> <table> <tr> @for (var i = 0; i < Model.Clubs.Count; i++) { if (i % 3 == 0) { @:</tr><tr> } <td> @Html.HiddenFor(model => model.Clubs[i].ClubID) @Html.EditorFor(model => model.Clubs[i].IsAvailable) </td> <td>@Html

EditorTemplate for List of complex type returns null, while EditorTemplate for its elements works fine

冷暖自知 提交于 2020-03-18 06:18:09
问题 I have a View in which the user can choose any number of Clubs by selecting checkboxex. The Clubs are a property of the main model with type List <ClubModel >. While refactoring I start out with this: @using (Html.BeginForm()) { <fieldset> <legend>Voor Select clubs </legend><br /> <table> <tr> @for (var i = 0; i < Model.Clubs.Count; i++) { if (i % 3 == 0) { @:</tr><tr> } <td> @Html.HiddenFor(model => model.Clubs[i].ClubID) @Html.EditorFor(model => model.Clubs[i].IsAvailable) </td> <td>@Html

500 Internal Server Error requesting any resource files (css, js, images) in an .Net MVC 3 site

…衆ロ難τιáo~ 提交于 2020-03-14 06:58:11
问题 UPDATE: Things I tried - see answer below for solution I installed a fresh MVC3 site and it served up the resources properly. That eliminated the machine.config settings as a problem. I then when section by section in the web.config to see if any particular changes in web.config caused the problem. When the configs were identical, the fresh site still worked and the old site was still broken. I uninstalled IIS, reinstalled IIS, and then installed apps again in an attempt to clear any settings

How to turn Razor Model into JS object in a Razor For Loop?

[亡魂溺海] 提交于 2020-02-29 04:31:54
问题 I have a Razor for loop: @foreach (var user in Model.Users) { <p class="active-text">Active: @user.LastActive</p> } I've just installed moment.js to format this DateTime() date using js. How can I pass the Razor model into a javascript function? I do have a JS viewmodel for this page, I'm just trying to avoid serializing the entire Model just because I need to apply some JS to a single field. How my viewModel stands right now: <script type="text/javascript"> $(document).ready(ko.applyBindings

How to turn Razor Model into JS object in a Razor For Loop?

血红的双手。 提交于 2020-02-29 04:30:30
问题 I have a Razor for loop: @foreach (var user in Model.Users) { <p class="active-text">Active: @user.LastActive</p> } I've just installed moment.js to format this DateTime() date using js. How can I pass the Razor model into a javascript function? I do have a JS viewmodel for this page, I'm just trying to avoid serializing the entire Model just because I need to apply some JS to a single field. How my viewModel stands right now: <script type="text/javascript"> $(document).ready(ko.applyBindings