asp.net-mvc-2

When using .net MVC RadioButtonFor(), how do you group so only one selection can be made?

人走茶凉 提交于 2019-11-26 08:16:57
问题 This one has me stumped, I have a strongly typed view that has this loop to generate radiobuttons: <% foreach (QuestionAnswer qa in Model.QuestionAnswers) { %> <%= Html.RadioButtonFor(model => model.QuestionAnswers[(int)qa.QuestionID - 1].AnswerValue, \"Checked\" ) %> <%= Html.Encode(qa.OptionValue) %> <% } %> It renders fine, but since the names are not the same, you can select more than 1 radiobutton. How can I group them so only 1 radiobutton can be selected? Any help would be appreciated!

Url.Action parameters?

夙愿已清 提交于 2019-11-26 08:05:27
问题 In listing controller I have, public ActionResult GetByList(string name, string contact) { var NameCollection = Service.GetByName(name); var ContactCollection = Service.GetByContact(contact); return View(new ListViewModel(NameCollection ,ContactCollection)); } In ASPX page I call, <a href=\"<%:Url.Action(\"GetByList\",\"Listing\" , new {name= \"John\"} , new {contact=\"calgary, vancouver\"})%>\"><span>People</span></a> I have a problem in the ASPX code... I can pull the records for the name

How to implement reCaptcha for ASP.NET MVC? [closed]

僤鯓⒐⒋嵵緔 提交于 2019-11-26 07:21:40
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed last year . How do I implement reCaptcha in ASP.NET MVC and C#? 回答1: There are a few great examples: Using ReCaptcha with ASP.NET MVC by Derik Whittaker MVC reCaptcha - making reCaptcha more MVC'ish. ReCaptcha Webhelper in ASP.NET MVC 3 ReCaptcha Control for ASP.NET MVC from Google Code. This

Using DataAnnotations with Entity Framework

让人想犯罪 __ 提交于 2019-11-26 06:46:17
问题 I have used the Entity Framework with VS2010 to create a simple person class with properties, firstName, lastName, and email. If I want to attach DataAnnotations like as is done in this blog post I have a small problem because my person class is dynamically generated. I could edit the dynamically generated code directly but any time I have to update my model all my validation code would get wiped out. First instinct was to create a partial class and try to attach annotations but it complains

Custom model validation of dependent properties using Data Annotations

余生颓废 提交于 2019-11-26 06:34:07
问题 Since now I\'ve used the excellent FluentValidation library to validate my model classes. In web applications I use it in conjunction with the jquery.validate plugin to perform client side validation as well. One drawback is that much of the validation logic is repeated on the client side and is no longer centralized at a single place. For this reason I\'m looking for an alternative. There are many examples out there showing the usage of data annotations to perform model validation. It looks

asp.net mvc: How to redirect a non www to www and vice versa

爷,独闯天下 提交于 2019-11-26 06:05:38
问题 I would like to redirect all www traffic to non-www traffic i have copied this into my web.config <system.webServer> / <rewrite> / <rules> <rule name=\"Remove WWW prefix\" > <match url=\"(.*)\" ignoreCase=\"true\" /> <conditions> <add input=\"{HTTP_HOST}\" pattern=\"^www\\.domain\\.com\" /> </conditions> <action type=\"Redirect\" url=\"http://domain.com/{R:1}\" redirectType=\"Permanent\" /> </rule> per this post How to redirect with "www" URL's to without "www" URL's or vice-versa? but I got

Has anyone implement RadioButtonListFor<T> for ASP.NET MVC?

試著忘記壹切 提交于 2019-11-26 05:59:38
There was an Html.RadioButtonList extension method in ASP.NET MVC Futures. Has anyone found a code for a strongly typed version RadioButtonListFor<T> . It would look like this in a view: <%= Html.RadioButtonListFor(model=>model.Item,Model.ItemList) %> Here is the usage in the aspx page <%= Html.RadioButtonListFor(m => m.GenderRadioButtonList)%> Here is the view model public class HomePageViewModel { public enum GenderType { Male, Female } public RadioButtonListViewModel<GenderType> GenderRadioButtonList { get; set; } public HomePageViewModel() { GenderRadioButtonList = new

How to create Custom Data Annotation Validators

倾然丶 夕夏残阳落幕 提交于 2019-11-26 05:28:31
问题 Wanting to create custom data annotation validation. Are there any useful guides / samples on how to create them? Firstly: StringLength with minimum and maximum length. I\'m aware .NET 4 can do this, but want to do the same in .NET 3.5, if possible being able to define minimum length only (at least x chars), maximum length only (up to x chars), or both (between x and y chars). Secondly: Validation using modulus arithmetic - if the number is a valid length, I wish to validate using the Modulus

Can&#39;t get sql server compact 3.5 / 4 to work with ASP .NET MVC 2

青春壹個敷衍的年華 提交于 2019-11-26 05:27:53
问题 I\'m using Visual Studio 2008 Pro. I\'m probably missing something very obvious here, but I\'ve been trying to get the CTP for Sql Server compact 4 to work in my asp.net mvc application. I can find next to no instruction on how to set this up or a working example application. My goal is a private install so I can just include it in my web app without having to do sql server setup on my domain hosting. This is really just me shooting the breeze and trying to figure this out. I don\'t plan to

Challenges with selecting values in ListBoxFor

北城以北 提交于 2019-11-26 05:24:45
问题 Working on my first ASP.Net MVC2 web app recently, I came across some issues when I needed to select multiple values in a list box. I worked around it with some jQuery, but went ahead and put together some very simple code to demonstrate. I\'m using EF for the model, with two entities - Customers and HelpDeskCalls: Controller: public ActionResult Edit(int id) { Customer currCustomer = ctx.Customers.Include(\"HelpDeskCalls\").Where(c => c.ID == id).FirstOrDefault(); List<HelpDeskCall>