开发者

Is it possible to modify page's namespace default value?

When I create a new page in my ASP.NET application I have This code automatically generated:

<%@ Page MasterPageFile="~/Site.master" Language="C#" AutoEventWireup="true" CodeBehind="Rh_Acceuil.aspx.cs" Inherits="PAGODE.RESSHUM.Rh_Acceuil" %>

It's really usefull! But the inherits tag is made with project's directories (the file is in de RESSHUM directory) bu开发者_JAVA技巧t I prefer to delete this part and have this:

...Inherits="PAGODE.Rh_Acceuil ...

But I have to do that manually each time..

So, is it possible to set an option with the aim of Visual Studio don't care about directories when he make this nameSpace?

Thanks for response..


There is a similar thread here:

How to NOT include Visual Studio Project folder names in generated namespaces

Looks like you would need Resharper, which is not free for standard developers.

Another option, although perhaps as tedious, is to add new pages in the main project then move them to the appropriate sub folder. At least then you wouldn't have to change the namespace in the aspx page and the code-behind.


In fact I've found a solution to do that without resharper (I'm sure it's a useful tool but expensive)

So, I just discover Item templates in Visual Studio, magic tool with which you can customize the way Visual studio make the files when you want a new item (.cs, .aspx, ...)

And in the templates you can put some values like $name$ or $itemname$ those values are replaced when file is generated.. (here by the name of windows user, and name of the file created)

I just make a file .aspx with all the things I want and for the namespace I just set

Inherits=$itemname$

and the namespace is just the file name in this case..

Thanks for help!..

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜