Including a file

XBLHacker

New Member
Hi all,<BR><BR>Does <!-- INCLUDE FILE="afile.aspx" --> work in ASP.Net? If so, what must surround your code in the afile.aspx file? I'm setting some variables in this file but I get an error saying they're undefined.<BR><BR>Thanks,<BR>D.The preferred way to include things in ASP.NET is to use User Controls. They're much more powerful and give you a lot more options, yet you can use them in the same way that you include a file in classic ASP as well.Wouldn't an include file be better for functions, classes, etc. Aren't user controls generally used to encapsulate UI elements and logic?Your right in that user controls are encapsulated, but you can pass values through the querystring into and out of user controls. Slightly inefficient though. If you need to use functions and what not, do not use user controls, but instead use code-behind pages.I have some function that are the same for all my pages, but some that are specific to each one. Is there a way to have more then one code-behind file, one generic and one specific.<BR><BR>Right now i am forced to copy the function again in each pages.good question why don't you test it for us. It wouldn't be hard to setup a sample page that tried to link 2 code behind pages. Without testing I can think of a problem use a generic function for all your pages and that is the return value from your function. This is unless your doing something simple like splitting values or doing a mass format or conversion into strings or integers.
 
Back
Top