www.webdeveloper.com
Results 1 to 4 of 4

Thread: including a file

  1. #1
    Join Date
    Feb 2004
    Posts
    37

    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 03:58 AM.

  2. #2
    Join Date
    Nov 2002
    Location
    Auburn, AL
    Posts
    9,222
    well are you just includeing some markup or are you trying to include a script?

    <!--#include File="includedfile.inc" -->
    or
    <!--#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
    <%
    Response.WriteFile ("Yourfile.inc")
    %>
    to include the file.
    Last edited by PeOfEo; 05-19-2004 at 02:17 PM.

  3. #3
    Join Date
    Feb 2004
    Posts
    37
    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 07:56 AM.

  4. #4
    Join Date
    Nov 2002
    Location
    Auburn, AL
    Posts
    9,222
    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.

    <%
    Response.WriteFile ("Yourfile.inc")
    %>

    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">

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles