Format:
Recent snippets matching tags of MVC
@using Adnug.web.AssetManager; @Html.TextBox(string.Empty, /* Name suffix */ ViewData.TemplateInfo.FormattedModelValue /* Initial value */ ) @this.BeginClientScript() <script type="text/javascript"> (function () { $("#@ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty)").datetimepicker(); })();
135 Views
1 comments
<!--In Layout - Note that the Render call is made at the end of the body.--> <!DOCTYPE html> <html> <head> <title>@Model.PageTitle</title> @Scripts.Add("jquery-1.6.min.js", 100) </head> <body> @Html.Partial("ToolbarView", Model) @RenderBody()
197 Views
no comments
public static class Scripts { const string ScriptsKey = "Scripts"; public static MvcHtmlString Add(string src, int priority = 0) { var scripts = GetScripts(); scripts.Add(new Script { Src = src, Priority = priority });
226 Views
3 comments
using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Web.Mvc; using Microsoft.Practices.EnterpriseLibrary.Validation; namespace Thoughtology.Web.Mvc { /// <summary> /// Maps a browser request to a data object and provides validation
241 Views
no comments
public ActionResult Index() { string modelDefinition = @"public class ChangePasswordModel { [Required] [DataType(DataType.Password)] [Display(Name = ""Current password"")] public string OldPassword { get; set; }
292 Views
no comments
I have an issue with accessing certain public objects of my RESx files. I am working with a MEF solution around an MVC3 application. My RESx files are implemented as public so they are accessible across assemblies. However, this seems to be limited. The solution I have is just changing the Custom Tool to PublicResXFileCodeGenerator. This allows switching the accessor that is applied to the class from internal to public. However, there is a catch when we throw MEF into the mix. Because MEF works on the principle of importing assemblies into an AppDomain and managing the export and import connections that it contains, the soft referencing that is implied does not connect one RESx file to another. Project Brand
187 Views
no comments
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, Inherited = true, AllowMultiple = true)] public class SomeAuthorization : AuthorizeAttribute { public SomeAuthorization() { } protected override bool AuthorizeCore(HttpContextBase httpContext) { var result = Service.SomeCheckMethod(HttpContext.Current.User);
146 Views
no comments
public class UnityControllerActivator : IControllerActivator { private IUnityContainer _container; public UnityControllerActivator(IUnityContainer container) { _container = container; }
194 Views
no comments
protected void RegisterDependencyInjection() { _container = new UnityContainer(); _container.RegisterType<IControllerActivator, UnityControllerActivator>(); _container.RegisterType<ISimpleService, DefaultSimpleService>(); DependencyResolver.SetResolver(new UnityDependencyResolver(_container)); }
150 Views
no comments
public class UnityDependencyResolver : IDependencyResolver { private IUnityContainer _container; public UnityDependencyResolver(IUnityContainer container) { _container = container; }
486 Views
no comments
// This does NOT work, but I believe it should. Fix below @if (!ChatPast.Web.Core.SiteMembership.HasActiveSession) { @{Html.RenderPartial("AnonymousAccountInfo" ); } } else { @{Html.RenderPartial( "RegisteredAccountInfo" ); } } // This does work, but why not above?
1029 Views
3 comments
<% Html.RenderAction("Menu"); %> <%= Html.Action("Menu") %> <% Html.RenderPartial("Menu"); %> <%= Html.Partial("Menu") %>
283 Views
no comments
public static class MapExtensions { public static IMappingExpression<IPagination<TSource>, IPagination<TDestination>> ConstructPagination<TSource, TDestination>(this IMappingExpression<IPagination<TSource>, IPagination<TDestination>> map) where TSource : class where TDestination : class { return map.ConstructUsing(src => new CustomPagination<TDestination>(src.ToList().Select(p => AutoMapper.Mapper.Map<TSource, TDestination>(p)), src.PageNumber, src.PageSize,
532 Views
no comments
using System; using System.Collections.Specialized; using System.Net; using System.Text; using System.Web; using System.Web.Mvc; using Moq; using MvcContrib.Web.Security; using NUnit.Framework;
233 Views
no comments
namespace System.DataAnnotations { using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.ComponentModel; using System.Reflection; using System.Globalization;
900 Views
no comments
// Map content before registering areas protected void Application_Start() { Content.Map<MyPortableArea>() .Master("~/Views/Shared/PA.master") .Title("PATitle") .Body("PAMain"); AreaRegistration.RegisterAllAreas();
249 Views
no comments
private static IEnumerable<Type> FindAllMessageHandlers() { var iMessageHandler = typeof(IMessageHandler); var types = from type in AppDomain.CurrentDomain.GetAssemblies().SelectMany(t => t.GetTypes()) let canInstantiate = !type.IsInterface && !type.IsAbstract && !type.IsNestedPrivate let isIMessageHandler = type.GetInterface(iMessageHandler.Name) != null where canInstantiate && isIMessageHandler select type;
265 Views
no comments
using System; using System.Linq; using System.Text; using System.Web.Mvc; using System.Web.Mvc.Html; using System.Web.Routing; namespace MvcSamples.Html { public static class UrlExtensions
1404 Views
1 comments
// controller public ActionResult Index([DefaultValue(1)] int page) { if (Request.IsAjaxRequest()) return PartialView("PagedDataControl", model.Data); return View(model); } // .aspx
377 Views
no comments
// Controller Action public JsonResult SearchItem(string nature, string term) { IEnumerable<Item> list = null; Transactional(() => { switch (nature.ToLowerInvariant()) { case "ricambi":
501 Views
no comments
Subscribe
Discuss
What's new
What is it
New Snippet
Recent Snippets
My Snippets
Web Code
Search
