小编MCa*_*ale的帖子

如何使用jQuery强制悬停状态?

请考虑这个CSS代码:

a { color: #ffcc00; }
a:hover { color: #ccff00; }
Run Code Online (Sandbox Code Playgroud)

这个HTML代码:

<a href="#" id="link">Link</a>
<button id="btn">Click here</button>
Run Code Online (Sandbox Code Playgroud)

最后,这个JS代码:

$("#btn").click(function() {
   $("#link").trigger("hover");
});
Run Code Online (Sandbox Code Playgroud)

我想让我的链接使用其伪类:单击按钮时悬停.我试图触发像mousemove,mouseenter,hover等事件,但任何人都可以.请注意,我想强制使用我的CSS伪类:悬停规范,而不是使用类似的东西:

$("#link").css("color", "ccff00");
Run Code Online (Sandbox Code Playgroud)

有人知道我该怎么做?非常感谢.

css jquery

65
推荐指数
2
解决办法
12万
查看次数

如何为未经过身份验证的用户隐藏我的菜单?

我已使用以下代码验证用户登录我的系统:

FormsAuthentication.SetAuthCookie(user, false);
Run Code Online (Sandbox Code Playgroud)

我想为未经过身份验证的用户隐藏我的系统菜单.像这样的东西:

<% if(???) {%>
   <ul id="menu>
      ...
   </ul>
<% } %>
Run Code Online (Sandbox Code Playgroud)

我怎样才能做到这一点?

谢谢.

authentication asp.net-mvc

7
推荐指数
1
解决办法
2978
查看次数

如何从hibernate.cfg.xml文件中获取连接字符串值?

我正在使用Fluent NHibernate,需要从hibernate.cfg.xml文件的connection.connection_string属性获取我的Connection String 来创建Session Factory:

private static ISessionFactory SessionFactory {
   get {
      return = Fluently.Configure()
         .Database(MySQLConfiguration.Standard.ConnectionString(c => c.FromConnectionStringWithKey("MyConnStr")))
         .Mappings(m => m.FluentMappings.AddFromAssemblyOf<FooMap>())
         .ExposeConfiguration(c => c.Properties.Add("hbm2ddl.keywords", "none"))
         .BuildSessionFactory();
   }
}
Run Code Online (Sandbox Code Playgroud)

我想替换来自hibernate.cfg.xml文件的连接字符串的MyConnStr(在我的web.config文件中)" c => c.FromConnectionStringWithKey("MyConnStr") " .

我尝试过使用NHibernate.Cfg.Environment.ConnectionString,但它没有用.

我怎么能得到这个?

谢谢.

c# asp.net nhibernate fluent-nhibernate

5
推荐指数
1
解决办法
7199
查看次数

如何在ASP.NET MVC中配置3个级别的URL?

使用ASP.NET MVC,我需要像这样配置我的URL:

www.foo.com/company:渲染查看公司

www.foo.com/company/about:渲染查看公司

www.foo.com/company/about/mission:渲染查看任务

如果"公司"是我的控制者而"约"是我的行动,应该是什么"使命"?

对于每个"文件夹"(公司,约和任务),我必须呈现不同的视图.

谁知道我该怎么做?

谢谢!

asp.net asp.net-mvc routing url-routing

5
推荐指数
1
解决办法
1316
查看次数

如何解决NHibernate延迟加载错误"没有会话或会话被关闭"?

我正在使用ASP.NET MVC,NHibernate和Fluent Hibernate开发一个网站,并在我尝试访问子对象时收到错误" 没有会话或会话关闭 ".

这些是我的域类:

public class ImageGallery {
    public virtual int Id { get; set; }
    public virtual string Title { get; set; }
    public virtual IList<Image> Images { get; set; }
}

public class Image {
    public virtual int Id { get; set; }
    public virtual ImageGallery ImageGallery { get; set; }
    public virtual string File { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

这些是我的地图:

public class ImageGalleryMap:ClassMap<ImageGallery> {
    public ImageGalleryMap() {
        Id(x => x.Id);
        Map(x => x.Title);
        HasMany(x => …
Run Code Online (Sandbox Code Playgroud)

nhibernate asp.net-mvc lazy-loading fluent-nhibernate

4
推荐指数
2
解决办法
8507
查看次数

如何构建通用存储库

我正在使用NHibernate在ASP.NET MVC中开发一个Web应用程序.

根据我在Google上发现的文章和教程,我正在为我的课程使用Repository.

我有10个类和10个存储库.今天我发现除了班级以外,90%的矿藏都是完全相同的.这是一个例子:

public class PromocaoRepository:IPromocaoRepository {
    private ISession Session;

    public PromocaoRepository() {
        this.Session = NHibernateSessionFactory.OpenSession();
    }

    public void Add(Promocao promocao) {
        using(ITransaction transaction = this.Session.BeginTransaction()) {
            this.Session.Save(promocao);
            transaction.Commit();
        }
    }

    public void Edit(Promocao promocao) {
        using(ITransaction transaction = this.Session.BeginTransaction()) {
            this.Session.Update(promocao);
            transaction.Commit();
        }
    }

    public void Remove(Promocao promocao) {
        using(ITransaction transaction = this.Session.BeginTransaction()) {
            this.Session.Delete(promocao);
            transaction.Commit();
        }
    }

    public Promocao GetById(int id) {
        return this.Session.Get<Promocao>(id);
    }

}
Run Code Online (Sandbox Code Playgroud)

有一种方法可以做我可以在我所有课程中使用的通用存储库吗?

如果可能的话,如果我需要为特定类创建特定方法,我该怎么办?

oop nhibernate asp.net-mvc design-patterns repository

4
推荐指数
1
解决办法
1702
查看次数

如何关闭NHibernate连接?

我使用ASP.NET MVC,NHibernate和MySQL完成了一个站点.在我的项目中,我有一些存储库类,每个类都使用如下代码的方法:

using(ISession session = NHibernateHelper.OpenSession()) {
    using(ITransaction transaction = session.BeginTransaction()) {
        session.Save(cidade);
        transaction.Commit();
    }
}
Run Code Online (Sandbox Code Playgroud)

我来自Classic ASP,所以如果与MySQL的连接实际上已经关闭,我会很有用.事实上,如果有一个像Classic ASP那样的连接,我会很有用.

我应该做些什么来明确关闭连接/会话还是"自动关闭"?

如果我的服务器上有很多打开的连接,有办法吗?

非常感谢你.

mysql database nhibernate asp.net-mvc

3
推荐指数
1
解决办法
1508
查看次数