mvccontrib

Can I constrain a route parameter to a certain type in ASP.net MVC?

不问归期 提交于 2020-01-06 06:54:49
问题 I have the following route: routes.MapRoute( "Search", // Route name "Search/{affiliateId}", // URL with parameters new { controller = "Syndication", action = "Search" } // Parameter defaults ); Is there a way I can ensure "affiliateId" is a valid Guid? I'm using MVCContrib elsewhere in my site and I'm fairly it provides a way to implement this kind of constraint.... I just don't know what it is! 回答1: You could write regex constraints: routes.MapRoute( "Search", // Route name "Search/

How to deal with more than one value per key in ASP.NET MVC 3?

对着背影说爱祢 提交于 2019-12-30 01:58:08
问题 I have the following problem: one of the system I'm working in most important features is a search page. In this page I have some options, like records per page, starting date, ending date, and the problematic one: type. One must have the possibility to choose more than one type (most of the time, all of them will be selected). To make that work, i created the following: <div> <label>Eventos:</label> <div> @Html.ListBox("events", Model.Events, new { style = "width: 100%" }) </div> </div> It

MvcContrib GridModel : Is it possible to do ActionSyntax in a GridModel

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-25 04:35:19
问题 I have a code in my aspx file which uses ActionSyntax, and i want to use a GridModel instead, but i don't know how to do that. Here is a sample of my aspx file : <% Html.Grid(ViewData.Model).Columns(column => { column.For(x => x.Id).Named("N° de contrat"); column.For(x => x.SubscriptionDate).Format("{0:d}").Named("Date de souscription"); column.For(x => x.SubscriptionOrigin).Named("Source"); column.For(x => x.Agent).Named("Agence(*)"); column.For(x => x.Agent).Named("Agent"); column.For(x =>

Html.EditorFor() — editor template in portable area

*爱你&永不变心* 提交于 2019-12-24 09:55:07
问题 I am trying to use a partial view editor template in my application using the Html.EditorFor method in my view. If the editor template is directly in the Views/Shared/EditorTemplates directory of my application, it works great. If the editor template in the Views/Shared/EditorTemplates directory of the portable area I am using in my application (which is my intent in using this so I can use the same template in more than just this application), it is not being found. Is there a way I can make

How to force http or https with Url.Action<tController>

这一生的挚爱 提交于 2019-12-24 08:57:51
问题 I'm using the strongly typed Url.Action method from MvcContrib to do all of my url generation on my site. For example: Url.Action<CategoriesController>(c => c.List()) Is there a way to force the urls generated by this method to use http or https? Right now it seems to just be creating urls relative to the current page. So, for example, if I'm on an https page it makes all my header and footer links use https even though I don't want those pages to be secure. Something like: Url.Action

MvcContrib Windsor Setup Component With Parameter

微笑、不失礼 提交于 2019-12-24 05:58:05
问题 I am using the MvcContrib library with Castle Windsor and I am having a problem with setting a parameter when I register a component. I have the following interfaces for classes that wrap a DataContext. I want to be able to specify which DataContext to use for different services because I am connecting to several databases to retrieve data. public interface IDataContext { DataContext Context { get; } } public interface IReportingDC : IDataContext { } public class Repository<T> : IRepository<T

MvcContrib Windsor Setup Component With Parameter

戏子无情 提交于 2019-12-24 05:57:03
问题 I am using the MvcContrib library with Castle Windsor and I am having a problem with setting a parameter when I register a component. I have the following interfaces for classes that wrap a DataContext. I want to be able to specify which DataContext to use for different services because I am connecting to several databases to retrieve data. public interface IDataContext { DataContext Context { get; } } public interface IReportingDC : IDataContext { } public class Repository<T> : IRepository<T

MvcContrib Grid Sorting on complex object

江枫思渺然 提交于 2019-12-21 19:49:47
问题 I am trying to work with MvcContrib Grid control. But I cannot seem to get the sorting to work on complex objects that hold other objects. I have setup my controller/classes/Views similar to the OP in this question. Sorting with MVCContrib I have tried to use the SortColumnName to my childobject.property but it gives me an error saying My main object does not have this property. This is my code snippet //POCO class class Issue { public int ID {get; get; } ..... public int priorityId {get; set

How To Write Unit Test For Method Returning JsonResult With RenderPartialViewToString?

巧了我就是萌 提交于 2019-12-20 10:57:23
问题 If you look at the example at this link: http://www.atlanticbt.com/blog/asp-net-mvc-using-ajax-json-and-partialviews/ How would one write a unit test for the JsonAdd method? I have a similar situation in my own code, but the RenderPartialViewToString errors when calling: ViewEngineResult viewResult = ViewEngines.Engines.FindPartialView I've tried different ways of trying to stub that call to no avail. Any help appreciated. Thanks. 回答1: Since ViewEninges is a static class, you can't mock it

How to style rows in the MVCContrib Grid based on their data?

守給你的承諾、 提交于 2019-12-20 10:41:16
问题 I am tinkering with the MVCContrib Grid and am stuck on how to format a row of data in the grid based on the data. For example, say we have a grid of products, where each product has data fields like name, price, and discontinued. I'd like to highlight all product rows that are discontinued. One workaround would be to use jQuery on the client-side to apply a CSS class to those rows where the discontinued cell is TRUE, but that seems like a brittle solution. I'm hoping there's a way to do it