asp.net-mvc-2

Html.ActionLink with id value from a dropdownlist

馋奶兔 提交于 2019-12-22 05:54:29
问题 I've got a dropdownlist: <%= Html.DropDownList("ddlNames", new SelectList(Model.NameList, "ID", "Name"))%> I've got an ActionLink: <%: Html.ActionLink("edit", "Edit", "Members", new { area = "MembersArea", id = XXX }, null)%> I want the value of the dropdownlist in the XXX. So I want to use values from controls on a view in the ActionLink. Is that possible in a simple manner? thanks, Filip 回答1: You can't do this because the html helpers execute at the server side while the dropdown value can

Handling MVC2 variables with hyphens in their name

五迷三道 提交于 2019-12-22 05:29:25
问题 I'm working with some third-party software that creates querystring parameters with hyphens in their names. I was taking a look at this SO question and it seems like their solution is very close to what I need but I'm too ignorant to the underlying MVC stuff to figure out how to adapt this to do what I need. Ideally, I'd like to simply replace hyphens with underscores and that would be a good enough solution. If there's a better one, then I'm interested in hearing it. An example of a URL I

Difference between MVC1 and MVC2

孤人 提交于 2019-12-22 05:28:09
问题 What is the difference between MVC1 and MVC2 ? Is everything in MVC1 also in MVC2? I am asking this question because there is a debate in my place of work. We can find resources and ebooks on MVC1, but not on MVC2. Should we use MVC1 in our portal?. Is AJAX functionality implemented the same in Web Forms for MVC2 as MVC1? Are there limitations in MVC2 vs. MVC1? (Can everything that can be done with AJAX in Web Forms MVC1 be done in MVC2?) 回答1: 1) See this Doc 2) Yes. 3) Yes. MVC is a much

Reference a control's ID created with TextBoxFor()

喜你入骨 提交于 2019-12-22 05:00:24
问题 I am loving ASP.NET MVC, keeping up with the releases/docs can sometimes be tricky, so maybe I'm just not getting something... I want to use a TextBoxFor(), and working with LabelFor() etc. is fine, all the magic happens for me. But if I create... <%=Html.TextBoxFor(x => x.LastName) %> And wanted to do something nice with jQuery, how would I get the ID of the control that was created? I could add a CSS class and use that to attach my jQuery, but for something I am doing I would like the ID...

How do I create a httppost getting same parameters from httpget?

走远了吗. 提交于 2019-12-22 04:43:17
问题 I have a controller to show up a model (User) and want to create a screen just with a button to activate. I don't want fields in the form. I already have the id in the url. How can I accomplish this? 回答1: You could use a hidden field inside the form: <% using (Html.BeginForm()) { %> <%= Html.HiddenFor(x => x.Id) %> <input type="submit" value="OK" /> <% } %> or pass it in the action of the form: <% using (Html.BeginForm("index", "home", new { id = RouteData.Values["id"] }, FormMethod.Post)) {

ResourceManager not selecting correct resource set when using custom culture

有些话、适合烂在心里 提交于 2019-12-22 03:55:12
问题 I have created a localized MVC website using the code found on this blog by Alex Adamyan. This is working great if I use an existing culture. However, I am trying to localize for Tagalog (tl or tl-PH). Windows does not have this culture built in so I have created one (I have tried both tl and tl-PH) as per the code below: public static void CreateCustomCultures() { var cultureBuilder = new CultureAndRegionInfoBuilder( "tl", CultureAndRegionModifiers.Neutral); cultureBuilder

Migrating ASP.NET (MVC 2) on .NET 3.5 over to .NET 4 #gotchas

佐手、 提交于 2019-12-22 00:34:58
问题 I've currently got a ASP.NET MVC 2 application on .NET 3.5 and I want to migrate it over to the new .NET 4.0 with Visual Studio 2010. Reason being that it's always good to stay on top of these things - plus I really like the new automatic encoding with <%: %> and clean web.config :-) So, does anyone have any experience they could share? Looking for gotchas and the likes. I guess this could also apply to any ASP.NET Forms projects aswell. TIA, Charles 回答1: Gotcha #1 - Changes application pool

Html.DropDownListFor not behaving as expected ASP.net MVC

╄→尐↘猪︶ㄣ 提交于 2019-12-22 00:19:12
问题 I am new to ASP.net MVC and I am having trouble getting dropdown lists to work correctly. I have a strongly typed view that is attempting to use a Html.DropDownListFor as follows: <%=Html.DropDownListFor(Function(model) model.Arrdep, Model.ArrdepOptions)%> I am populating the list with a property in my model as follows: Public ReadOnly Property ArrdepOptions() As List(Of SelectListItem) Get Dim list As New List(Of SelectListItem) Dim arriveListItem As New SelectListItem() Dim departListItem

Enum with mvc rendering in checkbox on my view, reaction of my controller?

戏子无情 提交于 2019-12-22 00:07:02
问题 If i got a list of checkbox in a View, and this list came from Enum (flags). If my checkbox as all the same name, did my controller will update automaticly my Enum (flags) values in my ViewModel with multiple selection ? Suppose i get in my View <% foreach (var t in Enum.GetValues(typeof(FoodType))) { Response.Write(t.ToString() + " "); %> <input type="checkbox" name="TypeOfFood" value="<%:(int)t %>" /> <% }%> My Controller working like this public ActionResult Manage(FoodEntity food) { } If

ASP.NET MVC 2 Validate Nested Objects

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-21 22:08:23
问题 According to the spec, complex child properties (aka "nested objects") are validated only if an input is found for one of the nested object's properties. For example, if Person has properties { string Name, Address HomeAddress } and Address has properties { Street, City }, and an action accepts parameter of type Person, then Person.HomeAddress.Street and Person.HomeAddress.City are only validated if the input form had input editors for those nested properties. Is there any way I can force MVC