ASP相当于Ajax?

时间:2013-08-02 16:05:09

标签: asp.net database asp-classic

奇怪的问题。我需要使用带有ID的JavaScript数组,以使用ID作为行ID从数据库中获取其他信息。

然后我需要使用这些附加信息并使用Ajax将其发送到另一个文件(aspx),然后Ajax将使用此信息来旋转图像。

除非我可以在同一个文件中使用ASP Classic和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")

希望你明白我在做什么?

2 个答案:

答案 0 :(得分: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 :(得分:1)

您可以一起使用C#.Net和ASP。这不是一个非常好的方式。我的理解是你必须首先创建C#项目然后添加任何asp页面。这将允许您从asp应用程序中调用C#页面。

我没有亲自完成其中的一项,但我已经看到它确实完成了所以我知道它在技术上是可行的。

相关问题