How to call .cs file from .aspx.cs file in asp.net c#?

Calling .cs (class file) from .aspx.cs (webform code behind file) in Asp.net C#:


This question is very general. And is faced by almost everyone including me. So, I have tried something which will be very helpful to everyone and beginners.

To understand this let's create a new website.

Select Asp.net Empty website. After writing the file name click OK button.

Right Click on the website title in the Solution Explorer -> Add -> Choose Web Form (or Add New Item) -> Write the appropriate web form name and click OK button.

Similarly, to add a class file. Right click on project title -> Add new item.

Choose Class file. Write the file name and click the Add button.


An alert box will appear, that will ask that all the class file will be added in 'App_Code' folder. Click 'Yes' button. It is not necessary; you can add your own folder. But, it's good to keep all your class file in 'App_Code' as it will keep your files well organized and easily managed.

ou can see that only your class file is added in the 'App_Code' folder.



 It not only store class file, but it can also store various other the files, such as typed data set, text files, and reports. And it will automatically compile at run-time.

 One of the important features of the App_Code folder is that only one .dll is created for the complete folder, irrespective of how many files it contains when we publish our project.



Related Post : 



















Comments

  1. Great article about calling .cs file from .aspx.cs file in asp.net c#, nice article, keep posting?

    ReplyDelete

Post a Comment

Popular posts from this blog