简体   繁体   中英

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.

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. 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.

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). 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.

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.

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

Master page tutorial: https://msdn.microsoft.com/en-us/library/wtxbf3hh.aspx

Three-tier architecture tutorial: http://www.codeproject.com/Tips/662107/Understand-Tier-Architecture-in-Csharp

Hope that helps you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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