2013-08-02 36 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