有一個CMS系統,並且有沒有後端文件的aspx頁面。我可以將服務器代碼直接添加到用<script language="C#" runat="server">
標記包裝的.aspx中。但編譯器會生成一個錯誤,因爲我在我的代碼中使用了LINQ,並且我沒有任何地方使用using System.Linq;
語句。而且我不能使用裏面的.aspx文件(錯誤再次)。我該怎麼辦?單文件ASPX和LINQ
<%@ Page Inherits="MyPage" MasterPageFile="~/Master.master" %>
<script language="C#" runat="server">
[System.Web.Services.WebMethod]
public static List<string> GetA()
{
MyDataContext db = new MyDataContext();
var result = from a in db.A
select a;
return result.ToList();
}
</script>
謝謝!還需要System.Collections.Generic。一切正常,偉大:) – Vitaly 2010-08-18 23:33:49
很高興幫助你! – Landmine 2010-08-18 23:35:19