我觉得不行,因为C#是编译型的,不像Asp,Php等是解释型的

解决方案 »

  1.   

    我也认为不行。和语言没有关系,和执行顺序有关系,如果先include,后执行服务器端代码,那么没有问题,但是应该是先执行服务器端代码,后include,这样当然就有问题了。有条件的话,最好能够尝试一下。
      

  2.   

    对不起,我写了一段代码,可以这样做。JScript1.js:
    <%Response.Write("Hope is a good thing");%>启动页面:
    <%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="WebApplication1.WebForm1" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    <html>
    <head>
    <title>WebForm1</title>
    <meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
    <meta name="CODE_LANGUAGE" Content="C#">
    <meta name="vs_defaultClientScript" content="JavaScript">
    <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
    </head>
    <body MS_POSITIONING="GridLayout">
    <form id="Form1" method="post" runat="server">
    <!--#include file="JScript1.js"-->
    </form>
    </body>
    </html>执行结果:
    Hope is a good thing
      

  3.   


    JScript1.js:
    <script runat=server>
    void ShowMe()
    {Response.Write("Hope is a good thing");}
    </script>启动页面:
    <%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="WebApplication1.WebForm1" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    <html>
    <head>
    <title>WebForm1</title>
    <meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
    <meta name="CODE_LANGUAGE" Content="C#">
    <meta name="vs_defaultClientScript" content="JavaScript">
    <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
    <!--#include file="JScript1.js"-->
    </head>
    <body MS_POSITIONING="GridLayout">
    <form id="Form1" method="post" runat="server">
    <%
    ShowMe();
    %>
    </form>
    </body>
    </html>执行结果:
    Hope is a good thing