asp.net-mvc-2

Asp.Net MVC DropDownList Data Binding

送分小仙女□ 提交于 2019-11-29 15:13:08
问题 <form id="Form1" runat="server"> <asp:DropDownList ID="dvmDrmList" runat="server"> <asp:ListItem>Theory</asp:ListItem> <asp:ListItem>Appliance</asp:ListItem> <asp:ListItem>Lab</asp:ListItem> </asp:DropDownList> </form> I want to bind this DropDownList in controller. I mean how can I get the value of the dropDownList in the action method in controller class. Thanks. 回答1: I see that you are using forms with runat="server" and asp:XXX web controls. Those are notions should never be used in ASP

Could not load file or assembly 'System.Web.Mvc' or one of its dependencies

感情迁移 提交于 2019-11-29 15:01:00
问题 I have this new MVC application which I have installed on Windows 2008 Server. And get the following message when I run the localhost. I have checked in the Bin folder, and can confirm that the Systems.Web.MVC is there. And the version of the file is, 2.0.50217.0 And in the web.config I have defined this assembly, Can any one help? See the error message below: ----ERROR MESSAGE------------------------------ Server Error in '/' Application. -----------------------------------------------------

what is the use of RouteValueDictonary routeValues in Html.BeginForm()

家住魔仙堡 提交于 2019-11-29 14:45:31
@{ ViewBag.Title = "About Us"; } @using (Html.BeginForm(new RouteValueDictionary { {"Action","Index"}})) { <input type="submit" value="submit"/> } When I render <form action="/Home/Index" method="post"><input type="submit" value="submit"/> Is this the actual use of RouteValueDictonary. If so I can do this do by HTML.BeginForm("About","Home") Can some one explain the actual use of RouteValueDictonary. Any help will be appreciated. This is also useful when implementing the ActionFilterAttribute for Redirection purpose. The basic usage of this class is to define the Action name, Controller Name

How to use a Base ViewModel in Asp.net MVC 2

[亡魂溺海] 提交于 2019-11-29 14:35:56
问题 As I familiarize myself with Asp.Net MVC, I am using MVC 2, I have noticed the use of a BaseViewData class in the Kigg project which I am unsure how to implement. I want each of my ViewModels to have certain values available. Using an iterface comes to mind but I am wondering what the best practice is and how does Kigg do it? Kigg public abstract class BaseViewData { public string SiteTitle { get; set; } // ...other properties } public class UserListViewData : BaseViewData { public string

JSON Date parameter passed to MVC Action is always null

心不动则不痛 提交于 2019-11-29 14:32:46
I have a range of parameters that are passed via jQuery Ajax to an MVC JsonResult action. For the most part, these arrive successfully, but there is a Date value that is not arriving at all. What considerations / formats do I need to use - or what approaches do I need to take - in order to get this date to arrive successfully? ...other code ... myStory.Deadline = new Date($('#story-deadline').val()); $.ajax({ url: '/Project/' + action[2] + '/AddStory', data: { Summary: myStory.Summary, Size: myStory.Size, Priority: myStory.Priority, Owner: myStory.Owner, Deadline: myStory.Deadline }, dataType:

In ASP MVC, how can I return a new view AND a file to the user?

早过忘川 提交于 2019-11-29 14:28:20
Thought I would pose this to the StackOverflow crowd since I've run out of ideas. I have a request from users that once a button is clicked, a PDF form is generated which they would like to automatically view, and once they close the PDF the page will already be a "Final page", not the page they clicked the button from. In my pre-final page with the button, the controller calls: return File(finalForm, "application/pdf", Server.HtmlEncode(finalForm)); But this has now passed the control to the client, I can't route to a different View. Any clever ideas on how I can also display a new view? I've

mock HttpContext.Current.Server.MapPath using Moq?

时间秒杀一切 提交于 2019-11-29 13:36:02
问题 im unit testing my home controller. This test worked fine until I added a new feature which saves images. The method that’s causing the issue is this below. public static void SaveStarCarCAPImage(int capID) { byte[] capBinary = Motorpoint2011Data.RetrieveCapImageData(capID); if (capBinary != null) { MemoryStream ioStream = new MemoryStream(); ioStream = new MemoryStream(capBinary); // save the memory stream as an image // Read in the data but do not close, before using the stream. using

How to remove flashing on persisting remotely populated jqgrid tree node

穿精又带淫゛_ 提交于 2019-11-29 12:48:22
jqGrid tree nodes are read from server using json data. Click in node reads child nodes from server. Code below is used to restore opened tree node if page is loaded. Only single node is opened always in tree. Controller assings node ids to autoClicked array and gridComplete opens nodes using this path. This causes grid flasinging on page load since multiple server requests buid grid multiple times. How to disable grid flashing ? Is it possible to prevent multiple jqGrid building and show only find jqGrid tree ? Answer in Send expanded TreeGrid Nodes in cookie works for fully populated grid

DefaultModelBinder not binding nested model

你说的曾经没有我的故事 提交于 2019-11-29 12:28:10
问题 Looks like others have had this problem but I can't seem to find a solution. I have 2 Models: Person & BillingInfo: public class Person { public string Name { get; set;} public BillingInfo BillingInfo { get; set; } } public class BillingInfo { public string BillingName { get; set; } } And I'm trying to bind this straight into my Action using the DefaultModelBinder. public ActionResult DoStuff(Person model) { // do stuff } However, while the Person.Name property is set, the BillingInfo is

Strongly Typed ActionLink In Asp.Net MVC 2?

余生长醉 提交于 2019-11-29 12:17:01
问题 I just downloaded VS.NET 2010 RC and created a new MVC project. It would seem that strongly typed ActionLinks are not in this release? Is this always going to be a "futures" thing? Or am I missing something? <%=Html.ActionLink<HomeController>(x => x.Index(),"Home")%> 回答1: No there is no ActionLink<> see ScottGu blog (( For performance reason. re: ASP.NET MVC 2: Strongly Typed Html Helpers Tuesday, January 12, 2010 2:32 AM by ScottGu @Anthony, but what about strongly typed ActionLinks? We aren