CodePaste Logo
New Snippet New Snippet Recent Snippets Recent Snippets My Snippets My Snippets Web Code Search Snippets Search
Sign inor Register
Format:
Recent snippets matching tags of MVC
C#
@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();
    })();
by erichexter   September 11, 2011 @ 9:52pm
Tags: MVC3
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()
by Rob Eisenberg   August 25, 2011 @ 10:05am
Tags: MVC, MVC3, Script
197 Views
no comments
 
C#
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
        });
by Rob Eisenberg   August 25, 2011 @ 10:01am
Tags: MVC, MVC3, Script
226 Views
3 comments
 
C#
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
by Enrico Campidoglio   May 23, 2011 @ 3:49am
241 Views
no comments
 
C#
public ActionResult Index()
{
    string modelDefinition = 
    @"public class ChangePasswordModel
        {
            [Required]
            [DataType(DataType.Password)]
            [Display(Name = ""Current password"")]
            public string OldPassword { get; set; }
by Jon Galloway   May 15, 2011 @ 3:35pm
292 Views
no comments
 
C#
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
by Bryan Wood   March 10, 2011 @ 10:49am
Tags: MVC, asp.net, MEF, resx
187 Views
no comments
 
C#
[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);
by Joel Mendoza   December 20, 2010 @ 11:28am
146 Views
no comments
 
C#
public class UnityControllerActivator : IControllerActivator
    {
 
        private IUnityContainer _container;
 
        public UnityControllerActivator(IUnityContainer container)
        {
            _container = container;
        }
by rjygraham   December 12, 2010 @ 6:21pm
Tags: MVC3, Unity
194 Views
no comments
 
C#
protected void RegisterDependencyInjection()
        {
            _container = new UnityContainer();
            _container.RegisterType<IControllerActivator, UnityControllerActivator>();
 
            _container.RegisterType<ISimpleService, DefaultSimpleService>();
            
            DependencyResolver.SetResolver(new UnityDependencyResolver(_container));
        }
by rjygraham   December 12, 2010 @ 6:20pm
Tags: MVC3, Unity
150 Views
no comments
 
C#
public class UnityDependencyResolver : IDependencyResolver
{
 
        private IUnityContainer _container;
 
        public UnityDependencyResolver(IUnityContainer container)
        {
            _container = container;
        }
by rjygraham   December 12, 2010 @ 6:13pm
Tags: MVC3, Unity
486 Views
no comments
 
C#
// 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?
by Michael Kennedy   November 11, 2010 @ 10:41pm
Tags: mvc3
1029 Views
3 comments
 
<% Html.RenderAction("Menu"); %>
<%= Html.Action("Menu") %>
 
<% Html.RenderPartial("Menu"); %>
<%= Html.Partial("Menu") %>
by Unknown (google)   September 23, 2010 @ 5:17am
283 Views
no comments
 
C#
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,
by John Nelson   August 09, 2010 @ 6:52pm
532 Views
no comments
 
C#
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;
by Pure Krome   June 01, 2010 @ 10:45pm
233 Views
no comments
 
C#
namespace System.DataAnnotations
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.ComponentModel;
    using System.Reflection;
    using System.Globalization;
by Bruno Figueiredo   May 22, 2010 @ 4:50pm
900 Views
no comments
 
C#
// Map content before registering areas
protected void Application_Start()
{
    Content.Map<MyPortableArea>()
        .Master("~/Views/Shared/PA.master")
        .Title("PATitle")
        .Body("PAMain");
 
    AreaRegistration.RegisterAllAreas();
by John Nelson   May 19, 2010 @ 9:33pm
249 Views
no comments
 
C#
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;
by John Nelson   May 06, 2010 @ 7:03pm
265 Views
no comments
 
C#
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
by Bobby Diaz   April 08, 2010 @ 10:10pm
Tags: ASP.NET, MVC 2
1404 Views
1 comments
 
C#
// controller
public ActionResult Index([DefaultValue(1)] int page)
{
   if (Request.IsAjaxRequest())
      return PartialView("PagedDataControl", model.Data);
 
   return View(model);
}
 
// .aspx
by andreabalducci   March 30, 2010 @ 10:19am
377 Views
no comments
 
C#
// Controller Action
        public JsonResult SearchItem(string nature, string term)
        {
            IEnumerable<Item> list = null;
 
            Transactional(() =>
                              {
                                  switch (nature.ToLowerInvariant())
                                  {
                                      case "ricambi":
by andreabalducci   March 29, 2010 @ 2:42am
501 Views
no comments
 
brought to you by:
West Wind Techologies



If you find this site useful and use it frequently please consider making a donation to support this free service.
Donate