简体   繁体   English

如何访问aspx-control / indata导致了另一个(非aspx.cs)类?

[英]How to access aspx-control/indata trought another (non aspx.cs) class?

I got aspx and aspx.cs that's working with no issue, however, I need to move some code to another cs-class so it wont be a massive mess.. However, I cannot access aspx-controls/indata, whatever it's called, from another class. 我得到了没有问题的aspx和aspx.cs,但是,我需要将一些代码移到另一个CS类,这样就不会造成很多混乱。但是,无论如何,我都无法访问aspx-controls / indata,从另一个班级。

How can I do it? 我该怎么做?

Thanks 谢谢

Your question is vague...I don't exactly know what you're trying to accomplish. 您的问题含糊不清...我不完全知道您要完成什么。

If you are trying to move some .cs code to another class, I would just copy and paste it directly into the other class. 如果您尝试将某些.cs代码移至另一个类,则只需将其直接复制并粘贴到另一个类中即可。 You could then modify the references so that your code targets the new class and not the old class. 然后,您可以修改引用,以便您的代码针对新类而不是旧类。 I highly recommend separating your presentation, business, and data access logic so that you can make your code easy to maintain. 我强烈建议将演示文稿,业务和数据访问逻辑分开,以使代码易于维护。 Assuming class A is a WebForm code-behind class, you would just add the references accordingly to your business and data access layers to your project. 假设类A是WebForm代码隐藏类,则只需将引用相应地添加到项目的业务和数据访问层即可。

So you would: 1. Right click on references (within the project you want to add) 2. Add Reference 3. Select the appropriate projects 3.1 - This is assuming you have projects that separate your business logic and data logic (eg, MyBusinessLogicLayer - conventions are something like BusinessBO or BusinessBo - and something like MyDataLogicLayer -again, it's convention to have something like BusinessDA or BusinessDa. BusinessBO/BusinessDa are all projects). 因此,您将:1.右键单击引用(要添加的项目内)2.添加引用3.选择适当的项目3.1-假设您具有将业务逻辑和数据逻辑分开的项目(例如,MyBusinessLogicLayer-约定类似于BusinessBO或BusinessBo-类似于MyDataLogicLayer-约定,具有BusinessDA或BusinessDa之类的约定。BusinessBO/ BusinessDa都是项目)。 You can then create classes and create the logic you want to accomplish within them. 然后,您可以创建类并在其中创建要完成的逻辑。 You can create web controls within those classes that you use in your Code Behind pages. 您可以在“代码隐藏”页面中使用的那些类中创建Web控件。

If you are trying to make a copy of an entire Web Forms page (I'm assuming you're using webforms because you mention aspx and .cs, presumably a code-behind file), you can create a master page that has the stuff you want to accomplish and create a page that inherits from the master page. 如果您试图复制整个Web窗体页面(我假设您使用的是Webforms,因为您提到了aspx和.cs,大概是一个代码隐藏文件),则可以创建一个包含这些内容的母版页您想要完成并创建一个从母版页继承的页面。

Without more information, I can't really help you. 没有更多信息,我无法真正为您提供帮助。 Here are some resources you can check out: 您可以查看以下资源:

Master page ref from MSDN: https://msdn.microsoft.com/en-us/library/aa581781.aspx 来自MSDN的母版页参考: https : //msdn.microsoft.com/zh-cn/library/aa581781.aspx

Master page tutorial: https://msdn.microsoft.com/en-us/library/wtxbf3hh.aspx 母版页教程: https : //msdn.microsoft.com/zh-cn/library/wtxbf3hh.aspx

Three-tier architecture tutorial: http://www.codeproject.com/Tips/662107/Understand-Tier-Architecture-in-Csharp 三层体系结构教程: http : //www.codeproject.com/Tips/662107/Understand-Tier-Architecture-in-Csharp

Hope that helps you. 希望对您有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM