开发者

How set attribute to MVC2 user control type in declarative way

How can I set attribute to MVC2 user control defined in single file with content:

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>

I'm searching declarative solution. Something like this:

<%[DefaultProperty("Items")]%>
<%@ Control 开发者_开发知识库Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>

Thanks.


You would need to create a new class that inherits from ViewUserControl

public class SpecialAttribute : Attribute { }

[Special]
public class MyUserControl : ViewUserControl
{

}

And then in your partial view you would use the Inherits attribute like this:

<%@ Control Language="C#" Inherits="MvcApplication1.CustomViews.MyUserControl" %>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜