Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Tuesday 1 December 2015

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


Today in Engineer's World, we are discussing a C# query faced by a developer in very easy way. Posted By- +Manish Kumar Gautam +LIVE VIAR  +ASP.NET SOLUTIONS

Click imagination hunt to see latest Blogs


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.



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




Related Questions:

Q-1 Why class files need to add in 'App_Code' folder?
Ans. Files need to be add in 'App_Code' folder because:
A) 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.
B) Files can be easily accessible through the project.
C) 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.

Q-2 Can we access a class file that is declared in the 'App_Code' within our entire application?
Ans. Yes. Files declared can be easily accessible through the project.

Click imagination hunt to see latest Blogs

Keep learning and sharing...

3 comments:

  1. I was able to find good info from your content.

    ReplyDelete
  2. Very nice write-up. I definitely appreciate this site.

    Keep it up!

    ReplyDelete
  3. I visit every day a few web pages and websites to read articles, however this weblog gives
    feature based writing.

    ReplyDelete

Featured post

Think that makes you rich and richer

 Napolean said: “You can think and grow rich, but if you can be brought up like most people with work and you won't starve, this wil...