开发者

page method in base page or master page

Where's the best place to put a page method so that it's available in every page? The page method is called from the client with a jquery $.ajax{...} function: it sends and开发者_如何转开发 receives json objects. Should I put this page method in a base page or in the master page?

Thanks.


It is more consistent to put such logic in a class that derives from System.Web.UI.Page. Every page that should have that logic should derive from your custom class.

The MasterPage should be used for containing logic relevant to the UI.

Also consider that you may add a page in the future, that should share the same design like the rest of the pages, but not the logic. In that case you would simply derive that page from System.Web.UI.page and use the MasterPage for layout purposes. If you had chosen the MasterPage, you'd either have a page that contains logic it should not, or you'd have to do a rewrite

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜