Count RRS feed

  • Question

  • User1564938493 posted

    Hi I have a piece of Javascript that calls an HTTP Handler and can call it several times (its for uploadify multi image uploader if this helps). Whats the best way to count the number of times the javascript uses the HTTP Handler. Here is the code


      <script type="text/javascript">
            $(function () {
                    'swf': 'scripts/uploadify.swf',
                    'itemTemplate': '<div id="${fileID}" class="uploadify-queue-item">\
                        <div class="cancel">\
                            <a href="javascript:$(\'#${instanceID}\').uploadify(\'cancel\', \'${fileID}\')">X</a>\
                        <span class="fileName">${fileName} (${fileSize})</span><span class="data"></span>\
                    'buttonText': 'Browse Files',
                    'uploader': 'uploadVB.ashx?StockID=<%=request.querystring("stockID") %>',
                    'method': 'post',
                    'fileTypeDesc': 'Image Files',
                    'fileTypeExts': '*.jpg;*.jpeg;*.gif;*.png',
                    'multi': true,
                    'auto': true

    and the handler is


    <%@ WebHandler Language="VB" Class="UploadVB" %>
    Imports System
    Imports System.Web
    Imports System.IO
    Imports System.Data
    Imports System.Web.Configuration
    Imports System.Web.UI
    Public Class UploadVB : Implements IHttpHandler
        Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
            Dim postedFile As HttpPostedFile = context.Request.Files("Filedata")
            Dim strStockID As String = context.Request.QueryString("stockID")
            Dim savepath As String = ""
            Dim tempPath As String = ""
            tempPath = System.Configuration.ConfigurationManager.AppSettings("FolderPath")
            savepath = context.Server.MapPath(tempPath)
            Dim filename As String = postedFile.FileName
            If Not Directory.Exists(savepath) Then
            End If
            postedFile.SaveAs((savepath & "\") & strStockID & "_" & filename)
            context.Response.Write((tempPath & "/")  & strStockID & "_" &  filename)
            context.Response.StatusCode = 200
            '' insert into DB
            Dim cn As New SqlClient.SqlConnection(WebConfigurationManager.ConnectionStrings("cn").ConnectionString)
            Dim cmd As New SqlClient.SqlCommand("INSERT INTO image_bank (stockID, imageFile, datetimestamp) VALUES (@stockID,@imageFile,@datetimestamp)", cn)
            cmd.Parameters.AddWithValue("@stockID", strStockID)
            cmd.Parameters.AddWithValue("@imageFile", strStockID & "_" & filename)
            cmd.Parameters.AddWithValue("@datetimestamp", DateTime.Now)
                Dim rowsAffected As Integer = cmd.ExecuteNonQuery()
            Catch ex As Exception
            End Try
        End Sub
        Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
                Return False
            End Get
        End Property
    End Class

    Thanks in advance




    Wednesday, January 30, 2013 3:30 PM


  • User1564938493 posted

    I just but a Count Select statement in the ashx - works fine

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, February 20, 2013 4:00 PM