asp.net MVC2 初探十六

最近做项目遇到很多令人头疼的问题,首先是JS单独文件的引用。先看看我的文件夹结构。
asp.net MVC2 初探十六_第1张图片
看见了吧我在Project下建了一个文件夹叫SysManage。在它下面我放了个JS文件。
然后我在页面调用
< asp:Content ID ="Content4" ContentPlaceHolderID ="HeadContent" runat ="server" >
         < script type ="text/javascript" src ="../../../Scripts/Project/SysManage/orgmanager.js" > </script>
</asp:Content>
看见了吧。可是运行后却发现什么东西也没有,呕了半天,愣是没有找到答案。
最后无意中脑子闪出一个东西-路由。我靠,打开路由
    routes.MapRoute(
                                 "Default", // Route name
                                 "SysManage/{controller}/{action}/{id}", // URL with parameters
                                 new { controller = "Code", action = "Index", id = UrlParameter.Optional } // Parameter defaults
                        );
于是我觉得是路由的问题,于是将Scripts文件夹下的SysManage改为SysManages,运行结果正常。唉,不过还是不明白为什么不改文件夹名下面这个请求发不出去
jQuery( "#dataGrid").jqGrid({
                datatype: "json",
                url: "/SysManage/Orga/selectOrg/",
                height: 310,
                width: 550,
                pager: '#pager', // 导航栏
希望看到本文章的兄弟能指点迷津,最后奉上我写的Nhibernate的一些常用方法

using System;
using System.Collections;
using System.Collections.Generic;
using NHibernate;
using Spring.Data.NHibernate;
using Spring.Data.NHibernate.Generic;
using NHibernate.Criterion;
using Spring.Data.NHibernate.Support;
namespace Utility
{
         public class HibernateGet : IHibernateCallback
        {
                 private Type type;
                 private object primaryKey;
                 public HibernateGet(Type type, object primaryKey)
                {
                         this.type = type;
                         this.primaryKey = primaryKey;
                }
                 public object DoInHibernate(ISession session)
                {
                         return session.Get(type, primaryKey);
                }
        }
         public class HibernateGetAggValue<T> : IHibernateCallback
        {
                 private ProjectionList projectionList;
                 private ICriterion[] criterions;
                 private Type type;
                 public HibernateGetAggValue(ProjectionList projectionList, ICriterion[] criterions, Type type)
                {
                         this.projectionList = projectionList;
                         this.criterions = criterions;
                         this.type = type;
                }
                 public object DoInHibernate(ISession session)
                {
                        ICriteria crit = session.CreateCriteria(type);
                         for ( int i = 0; i < criterions.Length; i++)
                        {
                                crit.Add(criterions[i]);
                        }
                        crit.SetProjection(projectionList);
                         return crit.List<T>();
                }
        }
         public class HibernateGetAll<T> : IHibernateCallback
        {
                 private Type type;
                 public HibernateGetAll(Type type)
                {
                         this.type = type;
                }
                 public object DoInHibernate(ISession session)
                {
                         return session.CreateCriteria(type).List<T>();
                }
        }

         public class HibernateSave<T, PK> : IHibernateCallback
        {
                 private T entity;
                 private PK pk;
                 public HibernateSave(T t)
                {
                         this.entity = t;
                }
                 public object DoInHibernate(ISession session)
                {
                        session.FlushMode = FlushMode.Auto;
                        pk = (PK)session.Save(entity);
                        session.Flush();
                         return pk;
                }
        }

         public class HibernateUpdate<T> : IHibernateCallback
        {
                 private T entity;
                 public HibernateUpdate(T entity)
                {
                         this.entity = entity;
                }
                 public object DoInHibernate(ISession session)
                {
                        session.FlushMode = FlushMode.Auto;
                        session.Update(entity);
                        session.Flush();
                         return null;
                }
        }

         public class HibernateSaveOrUpdate<T> : IHibernateCallback
        {
                 private T entity;
                 public HibernateSaveOrUpdate(T entity)
                {
                         this.entity = entity;
                }
                 public object DoInHibernate(ISession session)
                {
                        session.FlushMode = FlushMode.Auto;
                        session.SaveOrUpdate(entity);
                        session.Flush();
                         return null;
                }
        }

         public class HibernateDelete<T> : IHibernateCallback
        {
                 private T entity;
                 public HibernateDelete(T entity)
                {
                         this.entity = entity;
                }
                 public object DoInHibernate(ISession session)
                {
                        session.FlushMode = FlushMode.Auto;
                        session.Delete(entity);
                        session.Flush();
                         return null;
                }
        }

         public class HibernateFindByCriteria<T> : IHibernateCallback
        {
                 private ICriterion[] Criterions;
                 private Type type;
                 public HibernateFindByCriteria(ICriterion[] Criterions, Type type)
                {
                         this.Criterions = Criterions;
                         this.type = type;
                }
                 public object DoInHibernate(ISession session)
                {
                        ICriteria crit = session.CreateCriteria(type);
                         for ( int i = 0; i < Criterions.Length; i++)
                        {
                                crit.Add(Criterions[i]);
                        }
                         return crit.List<T>();
                }
        }

         public class HibernateGetListForPage<T> : IHibernateCallback
        {
                 private ICriterion[] criterions;
                 private Type type;
                 private int offset, length;
                 public HibernateGetListForPage(ICriterion[] criterions, Type
         type, int offset, int length)
                {
                         this.criterions = criterions;
                         this.type = type;
                         this.offset = offset;
                         this.length = length;
                }
                 public object DoInHibernate(ISession session)
                {
                        ICriteria criteria = session.CreateCriteria(type);
                         // 循环遍历添加约束条件
                         for ( int i = 0; i < criterions.Length; i++)
                        {
                                criteria.Add(criterions[i]);
                        }
                        criteria.SetFirstResult(offset);
                        criteria.SetMaxResults(length);
                         return criteria.List<T>();
                }
        }

         public class HibernateFindByCriterias<T> : IHibernateCallback
        {
                 private Order order;
                 private ICriterion[] criterions;
                 private Type type;
                 public HibernateFindByCriterias(Order order, ICriterion[] criterions, Type type)
                {
                         this.criterions = criterions;
                         this.order = order;
                         this.type = type;
                }
                 public object DoInHibernate(ISession session)
                {
                        ICriteria crit = session.CreateCriteria(type);
                         for ( int i = 0; i < criterions.Length; i++)
                        {
                                crit.Add(criterions[i]);
                        }
                         if (order != null)
                                crit.AddOrder(order);
                         return crit.List<T>();
                }
        }

         public class HibernateFindByCriteriass<T> : IHibernateCallback
        {
                 private int firstResult;
                 private int rowCount;
                 private Order order;
                 private ICriterion[] criterion;
                 private Type type;
                 public HibernateFindByCriteriass( int firstResult, int rowCount, Order order, Type type, ICriterion[] criterion)
                {
                         this.firstResult = firstResult;
                         this.rowCount = rowCount;
                         this.order = order;
                         this.criterion = criterion;
                         this.type = type;
                }

                 public object DoInHibernate(ISession session)
                {
                        ICriteria crit = session.CreateCriteria(type);
                         for ( int i = 0; i < criterion.Length; i++)
                        {
                                crit.Add(criterion[i]);
                        }
                         if (order != null)
                                crit.AddOrder(order);
                        crit.SetFirstResult(firstResult);
                        crit.SetMaxResults(rowCount);
                         return crit.List<T>();
                }
        }
}

你可能感兴趣的:(职场,asp.net,MVC2,休闲)