Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

AjaxFileUpload Tool. Set upload target dynamically

$
0
0

I'm trying to set the upload path dynamically. But the upload tool keeps taking the first path specified to the dropdownlist. It doesnt matter if I have the dropdownlist in a seperate update panel and tell the dropdownlist to stay on the selected index if there is a postback. How would I get the upload tool to use the value selected in the dropdownlist and not first value. Below is my code:

 protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                foldList.SelectedIndex = foldList.SelectedIndex;
            }
            else
            {
                Allfiles();
            }
        }
        public void Allfiles()
        {
            foldList.Items.Clear();
            String RootFold = ConfigurationSettings.AppSettings["RootPath"];
            string[] foldNames = Directory.GetDirectories(RootFold, "*", SearchOption.AllDirectories);

            foreach (string i in foldNames)
            {
                if (i.Contains(".") == true)
                {
                    //DO NOTHING
                }
                else
                {
                    foldList.Items.Add(i);
                }
            }
        }

public void AjaxFileUpload1_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
        {
            try
            {
               
               filePath = foldList.SelectedItem.Text.ToString() + @"\" + e.FileName;
                AjaxFileUpload1.SaveAs(filepaths);
                MessageBox.Show(filepaths);

            }
            catch (Exception error)
            {
                Label1.Text=(error.Message);
            }
        }
Here Is the HTML I have tried putting the 2 different controls in seperate update panels and that hasnt worked either

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>

</head>
<body>
<form id="form1" runat="server">
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<div align="center">
<asp:UpdatePanel ID="UpdatePanel1" runat="server" >
<ContentTemplate>
<asp:DropDownList ID="foldList" runat="server"
onselectedindexchanged="foldList_SelectedIndexChanged" AutoPostBack="True">
</asp:DropDownList>
</ContentTemplate>
</asp:UpdatePanel>
<br />
<asp:UpdatePanel ID="UpdatePanel2" runat="server" >
<ContentTemplate>
<asp:AjaxFileUpload ID="AjaxFileUpload1" runat="server"
onuploadcomplete="AjaxFileUpload1_UploadComplete"
onuploadstart="AjaxFileUpload1_UploadStart" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>


Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>