1

Based on dropdown i'm getting value and need to use for ajax file upload, now the problem is that i'm getting value properly, i'm using two ajax file upload(ajaxUpload1_OnUploadComplete & ajaxUpload2_OnUploadComplete), whenever i click the upload control for uploading files from the both the control goes to one upload method(ajaxUpload1_OnUploadComplete) only for uploading files. I need a solution for this. Thanks in advance.

In .cs

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {

        Session["Value"] = DropDownList1.SelectedItem.Text;
    }

protected void ajaxUpload1_OnUploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
    {
        String value = Session["Value"].ToString();
    }

 protected void ajaxUpload2_OnUploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
    {
        String value1 = Session["Value"].ToString();
    }

In .aspx

 <asp:AjaxFileUpload ID="AjaxFileUpload1" AllowedFileTypes="jpg,jpeg" MaximumNumberOfFiles="10" ThrobberID="1" ContextKeys="1"  OnUploadComplete="ajaxUpload1_OnUploadComplete" runat="server"/>

 <asp:AjaxFileUpload ID="AjaxFileUpload2" AllowedFileTypes="jpg,jpeg"  ThrobberID="2"  MaximumNumberOfFiles="10" ContextKeys="2" OnUploadComplete="ajaxUpload2_OnUploadComplete" runat="server" />
2
  • stackoverflow.com/a/14148071/360171 Commented Jan 24, 2013 at 13:42
  • @YuriyRozhovetskiy I already gone through with that, and found cannot have one or more ajaxfileupload in same page. So i left this concept, anyhow thank you for your kind help. Commented Jan 25, 2013 at 4:19

2 Answers 2

2

I think it a bug in the AjaxFileUpload I asked about this before and never got any reply except work a workaround here is the solution for this.

private string ContextKey = "";
public AjaxFileUpload()
            : base(true, HtmlTextWriterTag.Div)
        {
            if (HttpContext.Current.Items["lastAjaxFileUploadContextKey"] == null)
            {
                HttpContext.Current.Items["lastAjaxFileUploadContextKey"] = 1;
            }
            else
            {
                HttpContext.Current.Items["lastAjaxFileUploadContextKey"] = (int)HttpContext.Current.Items["lastAjaxFileUploadContextKey"] + 1;
            }

            ContextKey = HttpContext.Current.Items["lastAjaxFileUploadContextKey"].ToString();
        }
Sign up to request clarification or add additional context in comments.

2 Comments

in the main file constructor
sorry i couldn't get you, can you explain me in detail that what do you mean by main file??
1

I was also faced the same problem, so just I removed the second Ajaxfileupload control , and I upload the files based on the dropdown selected value. I am just using single fileupload control, and add the Dropdownlist selectedindexchanged event, in that you set the path accordinglny.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.