2013-08-02 34 views
1

奇怪的問題。我需要使用帶有ID的JavaScript數組,從數據庫中獲取更多信息,並使用ID作爲行ID。ASP相當於Ajax?

我需要再使用此附加信息,並將其發送給使用Ajax另一個文件(CSS),然後將利用這些信息來旋轉圖像。

除非我可以在同一文件中使用ASP經典,和ASP.NET(C#)? - 或者我可以使用或多或少相同的ASP代碼來訪問我的數據庫?

旋轉腳本

<%@ Page Language="C#" Debug="true" %> 
<%@ Import Namespace="System" %> 
<%@ Import Namespace="System.Drawing" %> 
<%@ Import Namespace="System.Web" %> 

<script runat="server"> 
protected void Page_Load(object sender, EventArgs e) 
{ 
    //string url = Request.QueryString["url"]; 
    string url = @"C:\inetpub\wwwroot\testing\image.jpg"; 
    string rotate_dir = Request.QueryString["dir"]; 

    //create an image object from the image in that path 
    System.Drawing.Image img = System.Drawing.Image.FromFile(url); 

    //Rotate the image in memory 
    if (rotate_dir == "clockwise") 
    { 
     //Rotate clockwise 
     img.RotateFlip(RotateFlipType.Rotate90FlipNone); 
    } else if (rotate_dir == "anticlockwise") 
    { 
     //Rotate anti-clockwise 
     img.RotateFlip(RotateFlipType.Rotate90FlipXY); 
    } 

    //Delete the file so the new image can be saved 
    System.IO.File.Delete(url); 

    //save the image to the file 
    img.Save(url); 

    //release image file 
    img.Dispose(); 
} 
</script> 

我用它來訪問我的數據庫

'Create connection and load users database 
set conn=Server.CreateObject("ADODB.Connection") 
conn.Provider="Microsoft.ACE.OLEDB.12.0" 
conn.Open Server.MapPath("/nightclub_photography/data/database/jamsnaps.mdb") 

希望你明白我想要做什麼?

+0

對不起,不,對我沒有意義。我看到你旋轉圖像,Asp Classic與此有什麼關係?數據庫是什麼? –

+0

@HanletEscaño我覺得他沒有得到這樣的Asp.NET還支持ACCESS或舊格式的數據庫連接,並認爲他必須使用ASP的經典之作datafetching :( – Vogel612

回答

1

正如你應該知道的,你可以在asp-classic中自由使用Javascript(以及ajax)。

這意味着你可以輕鬆地做到以下幾點;

set conn = Server.CreateObject("ADODB.Connection") 
set rs = Server.CreateObject("ADODB.Recordset") 
conn.open Server.MapPath("foobar path") + ", Microsoft.ACE.OLEDB.12.0" 
%><script type="text/javascript"> 
rotationArray = Array(id_Array.length); 
for(int i = 0; i < id_Array.Length; i++ 
{ 
    <% rs.open("SELECT rotation FROM images WHERE id="+ id_Array[i])%> 
    rotationArray[i] = <%= rs("rotation") %>; 
    <%rs.close() %> 
} 

//send rotationArray via ajax 

但總的來說,我建議你使用數據庫工具的asp.NET來代替。 然後您只需將您的JS-IDArray發送到aspx文件並在那裏進行處理。

參考,您可以檢查here

1

您可以使用C#.Net和ASP在一起。它不是一個很好的方式來做到這一點。我的理解是你必須先創建C#項目然後添加任何asp頁面。這將允許你從asp應用程序中調用你的C#頁面。

我還沒有親自做過這些中的一個,但我已經看到了肯定這樣做,我知道它的技術上是可行的。

+0

我知道這是可能的...但它不是真的值得在我們公司的努力中,我們將此作爲臨時解決方案,因爲我們將Intranet遷移到c# – Vogel612