include .ascx into a C# file

  • Thread starter Thread starter royend
  • Start date Start date
R

royend

How may I include a .ascx-file into my C#-file?
I have read somewhere that the usual include is no longer supported
for ASP.NET C#, but is there someway around this? The file to be
included is necessary for a lot of my C#-files, and by creating a
common file it will be much easier to edit only the one file.

Also, I am very keen to avoid using .dll-files, as this makes later
edits harder to accomodate.
Looking forward to your reply.

royend.
 
royend,
This is really an ASP.NET Group question, its not C# language group specific.

ASCX files are controls, and you have to add them to the ASPX markup portion
of the Page. You can drag the control onto the designer surface from the
Solution Explorer view.

You can also add an ascx file programmatically with the LoadControl method,
which sounds more like what you ar trying to do.
Peter
 
royend,

Using DLL files doesn't make edits harder to accomidate, it's like any
other piece of code, you change it, compile it, and distribute it. Also, if
it were allowed in the way you wish, including massive code documents on
multiple pages is going to have a detrimental effect on performance.

You can use the App_Code directory to have standalone files which will
be compiled into dlls by the ASP.NET runtime, and all you have to do is
maintain the file. Here is a link with more information:

http://dotnetjunkies.com/QuickStartv20/aspnet/doc/pages/code.aspx
 
Back
Top