asp.net-mvc-2

T4MVC and duplicate controller names in different areas

爱⌒轻易说出口 提交于 2019-12-05 09:03:27
In my application I have controller named Snippets both in default area (in application root) and in my area called Manage . I use T4MVC and custom routes, like this: routes.MapRoute( "Feed", "feed/", MVC.Snippets.Rss() ); And I get this error: Multiple types were found that match the controller named 'snippets'. This can happen if the route that services this request ('{controller}/{action}/{id}/') does not specify namespaces to search for a controller that matches the request. If this is the case, register this route by calling an overload of the 'MapRoute' method that takes a 'namespaces'

Difference between MVC1 and MVC2

独自空忆成欢 提交于 2019-12-05 08:29:38
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) See this Doc 2) Yes. 3) Yes. MVC is a much better fit for AJAX or any client side scripting in my opinion. 来源: https://stackoverflow.com/questions/2719586

Handling MVC2 variables with hyphens in their name

三世轮回 提交于 2019-12-05 08:07:01
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 want to handle is this: http://localhost/app/Person/List?First-Name=Bob&My-Age=3 with this Controller:

Properly registering JavaScript and CSS in MVC 2 Editor Templates

喜欢而已 提交于 2019-12-05 07:22:41
How do I properly register javascript blocks in an ASP.NET MVC 2 (RTM) Editor template? The specific scenario I'm in is that I want to use Dynarch JSCal2 DateTimePicker for my standard datetime picker, but this question is in general to any reusable javascript package. I have my template working properly now but it has my JS and CSS includes in my master page and I would rather only include these things if I actually need them: <link rel="stylesheet" type="text/css" href="../../Content/JSCal2-1.7/jscal2.css" /> <link rel="stylesheet" type="text/css" href="../../Content/JSCal2-1.7/border-radius

ASP.net mvc Call Action on DropDown Value Change

ε祈祈猫儿з 提交于 2019-12-05 06:41:34
问题 Ive got a dropdown on one of my views. This dropdown only has for entries. Basically i need to know how to call an action when the dropdown value is changed? My situation is: Im making a simple inbox page. The dropdown has the filter options: View All, View Invites, View Replies etc.. When the user selects a filter option from the dropdown I want to call to an action to return the new view with the filtered data. Any ideas? Im guessing it is somehow going to be a script attached to the

Cannot call action method 'System.Web.Mvc.PartialViewResult Foo[T](T)' on controller 'Controller' because the action method is a generic method

久未见 提交于 2019-12-05 06:12:36
Cannot call action method 'System.Web.Mvc.PartialViewResult FooT' on controller 'Controller' because the action method is a generic method <% Html.RenderAction("Foo", model = Model}); %> Is there a workaround for this limitation on ASP MVC 2? I would really prefer to use a generic. The workaround that I have come up with is to change the model type to be an object. It works, but is not preferred: public PartialViewResult Foo<T>(T model) where T : class { // do stuff } The code that throws that is inside the default ActionDescriptor: internal static string VerifyActionMethodIsCallable

passing dropdown's selected value from view to controller in mvc3?

偶尔善良 提交于 2019-12-05 06:08:25
问题 I have mvc3 web application. In that i have used EF and populate two dropdownlists from database. Now when i select values from those dropdownlists i need to show them inside webgrid how can i do this? @using (Html.BeginForm()) { @Html.ValidationSummary(true) <fieldset> <legend>Mapping</legend> <div class="editor-label"> @Html.Label("Pricing SecurityID") </div> <div class="editor-field"> @Html.DropDownListFor(model => model.ID, new SelectList(Model.ID, "Value", "Text"), "-- Select category --

TempData is not clearing as expected

本小妞迷上赌 提交于 2019-12-05 05:52:14
I'm working on an application using ASP.NET 4.0 and MVC 2.0. If it's in any way relevant, I'm using VS2010. I'm running into complications with TempData. I did not write the original code, but it isn't working correctly and I'm attempting to fix it. I don't have a lot of experience working with TempData and ViewData. I have an Index action as follows (pseudocode): public virtual ActionResult Index() { var vm = new IndexViewModel(); // some code here to set up the ViewModel if (TempData.ContainsKey("Success")) vm.Success = true; return View(MVC.Controller.Views.Index, vm); } And I have a POST

Reference a control's ID created with TextBoxFor()

不羁岁月 提交于 2019-12-05 05:45:01
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... so I could do something like: $('#LastName').(...) I know I could work it out in this case, and hack

jQuery WCF Service MVC2 VS2010 .NET 4.0 call with parameters fails

女生的网名这么多〃 提交于 2019-12-05 04:44:36
问题 In Visual Studio 2010 I created a new Ajax enabled WCF Service [ServiceContract(Namespace = "TestWCFAjax.Bridge")] [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] public class Bridge { [OperationContract] public string DoWork() { return "jQuery WCF call without parameters from MVC2 works." ; } [OperationContract] public string DoWork1(string parm) { return parm + " jQuery WCF call with parameters from MVC2 fails"; } In the Home Controllers