including a file in c#
I'm writing an application in .net using c#. I want to include a menu that I use on all my files, so I would modify it only once. Any idea how? Because it doesn't support the #include.
Last edited by nkeg; 05-19-2004 at 04:58 AM.
well are you just includeing some markup or are you trying to include a script?
<!--#include File="includedfile.inc" -->
<!--#include virtual="includedfile.inc" -->
is how you include with asp.net, asp classic, and shtml. It will be the same with vb.net c# or anything else.
If you need to you can use
to include the file.
Last edited by PeOfEo; 05-19-2004 at 03:17 PM.
Thank you PeOfEo for your help.Actually only the second worked(Response.WriteFile(("Yourfile.inc")) which was what I needed in my question. But I need to include a connection file but the #include doesn't work, although it's written in msdn. The compiler doesn't recognise the varaible I use in the included file. Any suggestions? Or, can you tell me how make it a class and import it if the include doesn't work?
Last edited by nkeg; 05-20-2004 at 08:56 AM.
You can't use an include to get variables or scripts. It will not work, the server will parse in the content in the file b eing included but not execute it. Also, using an include tag within a <script> or <% code block %> will fail because they cannot be inside of them.
would be your only solution. If you want to call an external scripts you can use an external class, a code behind, or using script src
<script runat="server" language="VB" src="mycodefile.vb">
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)