Search code examples
c#.nethandleruploadify

Uploadify pass formdata variable to handler.ashx


I am trying to send parameters from my .aspx page into my handler.ashx with the help of "formdata" in uploadify using .net and c# when I upload a file. The parameters are take from textboxes that have values in the. The code is:

 <script type = "text/javascript">
     $(document).ready(function() {
         $("#<%=FileUpload1.ClientID %>").uploadify({
             'swf': 'Scripts/uploadify.swf',
             'uploader': 'Handler.ashx',
             'auto': true,
             'multi': true,
             'buttonText': 'Select File(s)',
             'removeCompleted' : false,
             'fileTypeDesc' : 'PDF Files',
    'fileTypeExts' : '*.pdf',
    'formData' : { "id": "<%=TBcustnom.Text %>", "pwd": "<%=Pwd.Text %>" }


         });
     });

handler.ashx only receives the first value (id), but not whats in the pwd part.

string id = context.Request["id"]; 
string pwd = context.Request["pwd"];

How do I configure the javascript to send both parameters? or how do I configure the handler.ashx to receive the pwd as well?

Best regards


Solution

  • The only thing I needed to do was to look at the right place.

    string id = context.Request["id"]; 
    string pwd = context.Request["pwd"];
    

    this is supposed to be

    string id = context.Request.Form[1]; 
    string pwd = context.Request.Form[2];
    

    Take care!