English 中文(简体)
a. 为1英特网上页面制作多个剪辑
原标题:making multiple c# file for one asp.net page
  • 时间:2010-04-20 07:42:26
  •  标签:
  • asp.net

供我项目使用(如p.net) i 在1 000条左右的c#代码上写了一页。 它包括这么多的职能。 问题正在变得复杂,而我会在一页上写更多的法典。 • 如何为一页纸面页提供多个剪辑? 我尝试在2008年增加新班。 但是,从一个档案到另一个档案中要求一项功能是产生错误的(目前档案中没有项目)。 如何做到这一点?

最佳回答

部分课程将使你能够把大班分成许多档案。 然而,我建议这不是理想的解决办法。

  • You could create other classes that your page uses to perform a lot of its functionality.

  • You could move some of the functionality into UserControls.

  • You could move some shared functionality into a master page and then have multiple pages to perform individual tasks.

问题回答

http://msdn.microsoft.com/en-us/library/wa80x488(VS.80).aspx“rel=“nofollow noretinger”>partial par。

虽然你可以将你的部分法典移至单独的<条码>部分类别档案中,但更可能的话说,长篇意味着,你的一些职能应当从密码(.aspx.cs)档案中移至单独的法典(cs)档案中。

在该网页上必须有一些密码,你发现自己是手。

简单的答复是使用部分类别

如果在另一份档案中有密码,就只给它一个名称空间,并将其列入原始网页。

页: 1

Newclass.cs
namespace myapp.functions
{
//code to include.
}

Page.aspx.cs
using myapp.functions;
// now you can use them

虽然我看到,为什么每个人都建议使用部分课程,但他们只提供单独档案中的代码实际分离。 我认为,你这里的问题不是将守则本身分开,而是将你的职能分成几个部分。

如果在逻辑上合在一起的网页上有功能,为什么不能在伙伴关系中提取。 NET控制,揭露这种控制中的事件,并使代码+功能按逻辑分类? 这将增加需要作出更大努力的范围,但将非常、更清洁和易于维持。 而且,如果你决定重新使用该网页的某些部分,如果该功能载于一页的代码而不是控制,则该功能将是复印机。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签