.net 引用外部js文件不起作用.
我在頁面裡引用js文件,但是運行卻不起作用。
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="Web_MasterPage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>未命名頁面</title>
<script language="javascript"type="text/JavaScript" src="../JavaScript/Script.js" ></script>
<link type="text/css" rel="Stylesheet" href="../CssStyle/Style.css" />
</head>
<body onload="showMessage();">
<form id="form1" runat="server">
<div class="Content_DIV">
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>
Script.js
function showMessage()
{
window.showModalDialog("modal.htm","dialogWidth=200px;dialogHeight=100px");
}
------解决方案--------------------
要不先用
Page.ClientScript.RegisterClientScriptInclude()方法试试。
这样还是不行,那就是别的问题了。