asp.net-mvc-2

Model binding form to a List using dropdown. binding failing 1 way for dropdown

核能气质少年 提交于 2019-12-11 06:33:24
问题 I have an action called Sessies. In this action i am creating 'Sessies' objects from a form. if they don't exist i add them in the DB, if there are already Sessies objects connected to the 'Reeksen' object, i load the 'Sessies' into the form so that they can be edited. so i have a create and edit in 1 and the same form. Also, a 'Reeksen' has a predefined number of 'Sessies' which can not be changed. so i let the user make all 'Sessies' in one time (cos the amount of sessies will be from 1 to

MVC2: How can I read control values for an action link?

夙愿已清 提交于 2019-12-11 06:25:32
问题 I'm passing in some model information to an ActionLink, but I'd also like to provide the action with the values of some inputs on the page. For example, if I had something like this: <input Name="MyInput" /> <%: Html.ActionLink("MyAction", "MyController", Model.Value); I'd like the action to be aware of both Model.Value (which is passed in via parameter), and the value of MyInput. Normally I would use a FormCollection, but I can't in this instance since I'm not doing a submit. So how can I

Asp.net MVC GridView edit columns option

让人想犯罪 __ 提交于 2019-12-11 06:18:52
问题 I have the view : <%= Html.Grid(Model.data).Columns(column => { column.For(x => x.results) .Action(item => Html.ActionLink(item.results,"Edit").ToString(), item => Html.TextBox("result",item.results).ToString(), item => (Model.data == item)) .Named("Results"); column.For(x => x.refId) .Named("Reference ID"); column.For(x => x.fileLocation) .Named("File Location"); }) .Attributes(style => "width:100%", border => 1) And the controller looks like: public ActionResult Index() { // IEnumerable

Best strategy for HTML partial rendering based on multiple dropdown values

巧了我就是萌 提交于 2019-12-11 06:14:06
问题 I have a View that renders something like this: "Item 1" and "Item 2" are <tr> elements from a table. After the user change "Value 1" or "Value 2" I would like to call a Controller and put the result (some HTML snippet) in the div marked as " Result of... ". I have some vague notions of JQuery. I know how to bind to the onchange event of the Select element, and call the $.ajax() function, for example. But I wonder if this can be achieved in a more efficient way in ASP.NET MVC2. 回答1: Here is

Silverlight, Grids, MVC, HTTP Post

半腔热情 提交于 2019-12-11 06:10:31
问题 I'm trying to create an editable grid using Asp.Net MVC 2 and Silverlight (specifically a grid that displays info from a db and allows users to update that info). So far I've managed to put a silverlight grid on an a view, using this technique However I have no way of getting the updated data from the silver light grid. Is there anyway to get these values posted back to my controller? I'm pretty new to Asp.Net MVC and I'm really only getting started using silverlight. Thanks for any help! 回答1

if(ModelState.IsValid) doesn't work with FormsCollection. What to use instead?

故事扮演 提交于 2019-12-11 05:58:20
问题 To validate a HttpPost action that's bound to a concrete type, I can use ModelState.IsValid public ActionResult Create(MyModelType myModel) { if(ModelState.IsValid) { // Do some stuff return RedirectToAction("Details", 0); } else { return View(); } } This obviously won't work with a FormCollection , because there is no model to validate public ActionResult Create(FormCollection collection) { if(ModelState.IsValid) // Never invalid { What should one use instead of ModelState.IsValid when the

Missing Project Template after installing ASP.NET MVC 2

纵然是瞬间 提交于 2019-12-11 05:24:34
问题 I have downloaded the ASP.NET MVC 2 Release version (using Web Platform Installer) as well as the downloading the file directly from the link in WPI. No error messages are reported after the install. When I go into Visual Web Developer and select Create New project I only the project reference to ASP.NET MVC version 1.0 and not version 2 (for clarity I have all the other project types, this is just in reference to the MVC projects). I have restarted, uninstalled and restarted and installed my

File input and validation in ASP.NET MVC 2

折月煮酒 提交于 2019-12-11 05:21:44
问题 Hi, It seemse like uploading of files is a tricky thing even in ASP.NET MVC2. I have placed a couple of intput(type file) on my form and when submitting thay are mapped to my viewmodel nicely. The problem is that if the ModelStat.IsValid is false then we will be returned to the same form and the fileinputs will be empty? I know that its possible to clear a input field(by replacing it) but I do not see how I could set the input properly? The users have to be able to see/change/remove the file

Session is null when redirect from one controller to another ASP.NET MVC

余生颓废 提交于 2019-12-11 05:03:42
问题 Why Session is null when redirection from one controller to another? And when I refresh the page again I find that the session object is not null and have data! First controller: HttpContext.Session["SiteCheckpoint"] = siteCheckpoint; //redirect to second page controller Response.Redirect(siteCheckpoint.FirstPageUrl + "?rf =" + referenceId); Second controller: if (HttpContext.Session[Resources.SessionParameter.SiteCheckpoint] != null) { GetCheckpointData(); } else { //Raise error page } I

Display two properties in the dropdownlist

不想你离开。 提交于 2019-12-11 04:57:11
问题 Database table Language languageID (Primary key) language People <%: Html.DropDownList("SprakID", new SelectList(ViewData["Sprak"] as IEnumerable, "languageID", "language", Model.languageID))%> Goal: Display the name of the language and what languageID in the DropDownList. Problem: Don't know how to display both language and languageID in the dropdownlist? 回答1: Add a property to your Language class, for example public string DataTextFieldLabel { get { return string.Format("{0} ({1})",