razor

ASP.NET MVC 3 Routing Multiple parameters without query string

笑着哭i 提交于 2020-01-02 21:00:35
问题 I have the below route setup but it is not coming out the way I am expecting. Yes I am still new to MVC. The way it is coming out is like this. http://localhost:29998/Home/States?make=Chrysler the way I want it to come out is like this http://localhost:29998/Home/Chrysler/States Then of course once you click on your state it would look like this. http://localhost:29998/Home/Chrysler/Florida I would realy love to be able to remove "home from that altogether and just leave it as http:/

Dollar sign and/or Dash breaking Razor's parser

你离开我真会死。 提交于 2020-01-02 18:56:45
问题 the end-result i'm trying to render: <input type="radio" name="options" id="options_1" />$1 - A Not Very Expensive Chocolate <input type="radio" name="options" id="options_2" />$10 - A Kinda Expensive Chocolate <input type="radio" name="options" id="options_3" />$100 - A Really Expensive Chocolate From this code: @foreach (var o in Model.Options){ <input type="radio" name="options" id=@("options_" + @o.ID) />$@o.PriceToAdd - @o.Label } If i drop both the '$' and the '-' from what should be

append two IEnumerable items

假如想象 提交于 2020-01-02 17:46:38
问题 IEnumerable<Addresses> AddressSet1=myServices.GetAddresses(LocationId1); IEnumerable<Addresses> AddressSet2=myServices.GetAddresses(LocationId2); I want to combine the above two AddressSets I tried IEnumerable<Addresses> AllAddresses=AddressSet1.Concat(AddressSet2) But after this when I try to access items from IEnumerable AllAddresses by on my razor view @if(!myHelper.IsNullorEmpty(model.AllAddresses ) { @Html.EditorFor(model => model.AllAddresses ) } and I am getting errors -- Illegal

What is a good way to pass a confirmation or error message back to a view?

耗尽温柔 提交于 2020-01-02 15:05:37
问题 When the user clicks the submit button on a form I want to return a success / failure message to the user and i'm wondering what the best way to send the message back to the user is. For example on a login form if the user enters an incorrect password i'd want the view to reload with a message telling them that login failed. Or on an update form the original view they had would show up with a message saying update was successful. My idea is to have a few partial views or HTML helpers that

What is a good way to pass a confirmation or error message back to a view?

萝らか妹 提交于 2020-01-02 15:05:23
问题 When the user clicks the submit button on a form I want to return a success / failure message to the user and i'm wondering what the best way to send the message back to the user is. For example on a login form if the user enters an incorrect password i'd want the view to reload with a message telling them that login failed. Or on an update form the original view they had would show up with a message saying update was successful. My idea is to have a few partial views or HTML helpers that

ASP.NET MVC 5 Editor for 2-dimensional array

删除回忆录丶 提交于 2020-01-02 14:56:53
问题 I have a model with two-dimensional array in it: public class Matrix { public ValidInt[][] Data; [Range(0, 8, ErrorMessage = "Введите ширину картины")] public int Width { get; set; } [Range(0, 8, ErrorMessage = "Введите ширину картины")] public int Height { get; set; } public Matrix(int w, int h) { Width = w; Height = h; Data = new ValidInt[w][]; for (int i = 0; i < w; i++) this.Data[i] = new ValidInt[h]; } public class ValidInt { [Range(0, 8, ErrorMessage = "Введите число, соответствующее

ASP.NET MVC 5 Editor for 2-dimensional array

瘦欲@ 提交于 2020-01-02 14:56:23
问题 I have a model with two-dimensional array in it: public class Matrix { public ValidInt[][] Data; [Range(0, 8, ErrorMessage = "Введите ширину картины")] public int Width { get; set; } [Range(0, 8, ErrorMessage = "Введите ширину картины")] public int Height { get; set; } public Matrix(int w, int h) { Width = w; Height = h; Data = new ValidInt[w][]; for (int i = 0; i < w; i++) this.Data[i] = new ValidInt[h]; } public class ValidInt { [Range(0, 8, ErrorMessage = "Введите число, соответствующее

ASP.NET MVC 5 Editor for 2-dimensional array

江枫思渺然 提交于 2020-01-02 14:55:10
问题 I have a model with two-dimensional array in it: public class Matrix { public ValidInt[][] Data; [Range(0, 8, ErrorMessage = "Введите ширину картины")] public int Width { get; set; } [Range(0, 8, ErrorMessage = "Введите ширину картины")] public int Height { get; set; } public Matrix(int w, int h) { Width = w; Height = h; Data = new ValidInt[w][]; for (int i = 0; i < w; i++) this.Data[i] = new ValidInt[h]; } public class ValidInt { [Range(0, 8, ErrorMessage = "Введите число, соответствующее

Html.BeginForm not posting to server despite submit button

落花浮王杯 提交于 2020-01-02 11:26:52
问题 I have a standard form, which is wrapped into a Html.BeginForm. In the bottom there is a submit button. However, when clicking the button my controller isn't getting hit. I experience a reload of the page, but no code is hit. I've tried to debug on the controllers side and try code I could see get hit, but it's definetely not being hit. Razor - Index.cshtml under /Views/BuyBitcoins/Index.cshtml: @using (Html.BeginForm("BuyBitcoinsNow", "BuyBitcoins",FormMethod.Post)) { <h3>@ModelRes

(MVC 3 Razor) - Easier way to loop through 3 column div

北战南征 提交于 2020-01-02 09:09:53
问题 At the moment I'm using the following code in my CSHTML: @{int i = 0;} @foreach (var item in Model.Traders) { if ((i++ % 3) == 0) { if (i != 1) { @:</div> } @:<div class="row"> } @:<div class="four column"><div class="panel new"><h3 class="dotted"><strong>@item.Title</strong></h3><p>@item.Description</p><code><div class="panel pick"></code></div></div> } @if (i != 0) { @:</div> } This outputs the following HTML: <div class="row"> <div class="four column"><div class="panel new"><h3 class=