Home Search Member List Faq Register Login  
UltimateAjax
Re: Ajax FileUpload control

Thread Starter: vasilaky   Started: 10-29-2008 5:50 PM   Replies: 1
 Karamasoft Support Forums » General Discussions » UltimateAjax » Re: Ajax FileUpload control
 Printable Version    « Previous Thread   Next Thread »
  29 Oct 2008, 5:50 PM
vasilaky is not online. Last active: 5/1/2009 10:59:27 AM vasilaky

Top 10 Posts
Joined on 02-12-2008
Posts 41
Ajax FileUpload control

Do you have an example of Ajax FileUpload control?chemas-microsoft-comSurprisefficeSurpriseffice" />>>

>

I have placed FileUpload control and a table control inside UltimateAjax tag. Everything works fine without chemas-microsoft-comSurprisefficeTongue Tiedmarttags" />t="on">Ajax but with t="on">lace wTongue Tiedt="on">Ajaxlace> the files that are uploaded do not display in the table. I made FileUpload invisible and when I click the button cmdAttach it bacomes visible and this part works fine with t="on">Ajax but the FileUploader appears to be broken inside t="on">lace wTongue Tiedt="on">Ajaxlace>.>>

I’m trying to wriete something  similar to gmail upload or to what Karamasoft's competitor does with AjaxUploader http://ajaxuploader.com/   >>

>

>

Here is some of my code:>>

>

<head>>>

<script type="text/javascript" language="javascript">>>

            function SetAttach(arg) {>>

                DoUltimateCallback('ctl00_ContentPlaceHolder1_UltimateAjax2', arg);>>

            }>>

        </script>>>

>

</head>>>

>

>

>

<cc1:UltimateAjax ID="UltimateAjax2" runat="server" >>>

>

 <asp:FileUpload ID="FileUpload1" runat="server" Visible="False" Width="700px" style="position: static" />>>

>

 <asp:Table ID="tblAttach" runat="server" Font-Size="Small" Height="1px" Width="182px" style="left: 712px; overflow: auto; >>

position: relative; top: -19px"></asp:Table>>>

                >>

 </cc1:UltimateAjax>>>

>

>

  protected void Page_Load(object sender, EventArgs e)>>

{>>

        cmdAttach.Attributes.Add("onclick",SetAttach();return false;");>>

}>>

>

>

>

private void UltimateAjax2_Callback(object sender, Karamasoft.WebControls.UltimateAjax.CallbackEventArgs e)>>

    {>>

        >>

>

         FileUpload1.Visible = true;>>

        DisplayFiles();>>

             >>

    }


>>

protected void DisplayFiles()>>

    {>>

>

       >>

        if (Session["AttachedFiles"] == null) Session["AttachedFiles"] = new ArrayList();>>

>

       >>

        attchedfiles = (ArrayList)Session["AttachedFiles"];>>

     >>

        if (FileUpload1.PostedFile != null &&>>

                      FileUpload1.PostedFile.ContentLength > 0)>>

        {>>

            // attachFile.PostedFile.FileName contains >>

            // the full path of the file. We only want the file>>

            // so we delimit it by forward slashes into an array>>

>

            string[] tempFileName = FileUpload1.PostedFile.FileName.Split('\\');>>

>

            // attachFile.PostedFile exposes a System.IO.Stream>>

            // property named InputStream>>

>

            attchedfiles.Add(FileUpload1.PostedFile.FileName);>>

        }>>

>

        if (attchedfiles != null)>>

        {>>

            if (attchedfiles.Count > 0)>>

            {>>

                FileUpload1.Visible = true;>>

>

                cmdAttach.Text = "Attach another";>>

            }>>

            for (int i = 0; i < attchedfiles.Count; i++)>>

            {>>

                row = new TableRow();>>

                tblAttach.Rows.Add(row);>>

                cell = new TableCell(); row.Cells.Add(cell); cell.Width = 5;>>

>

                if (i % 2 == 0)>>

                {>>

                    cell.BackColor = Color.LightGray;>>

                }>>

                else>>

                {>>

                    cell.BackColor = Color.WhiteSmoke;>>

                }>>

                LinkButton lnkName = new LinkButton();>>

                cell.Controls.Add(lnkName);>>

                lnkName.ID = "plnkName" + i.ToString();>>

                lnkName.Text = "Remove";>>

>

                lnkName.CommandArgument = attchedfiles[i].ToString();>>

                linkbuttoneventhandler = new EventHandler(DeleteAttachments);>>

                lnkName.Click += linkbuttoneventhandler;>>

>

>

>

                // To Name>>

                cell = new TableCell(); row.Cells.Add(cell); cell.Width = 150;>>

                if (i % 2 == 0)>>

                { cell.BackColor = Color.LightGray; }>>

                else>>

                { cell.BackColor = Color.WhiteSmoke; }>>

>

                cell.ID = "file" + i.ToString();>>

                //string[] tempFileName = FileUpload1.PostedFile.FileName.Split('\\');>>

                string[] tempFileName = Convert.ToString(attchedfiles[i]).Split('\\'); >>

                cell.Text = tempFileName[tempFileName.Length - 1];>>

            }>>

        }>>

        >>

    }>>

>


  
  29 Oct 2008, 7:13 PM
Karamasoft is not online. Last active: 5/8/2018 10:36:45 AM Karamasoft

Top 10 Posts
Joined on 09-05-2004
Posts 6,820
Re: Ajax FileUpload control
We cannot compile your code because it uses a variable called cmdAttached but it doesn't exist in your page. Normally FileUpload control cannot be used in AJAX environment as is because it is not compatible with asynchronous postback and UltimateAjax control doesn't provide any specific functionality to enable AJAX for FileUpload control. As a matter of fact, FileUpload control is one of the controls that are not supported by Microsoft ASP.NET AJAX Framework due to security reasons and restrictions a browser implies.
  
 Page 1 of 1 (2 items)
Karamasoft Support Forums » General Discussions » UltimateAjax » Re: Ajax FileUpload control

You can add attachments
You can post new topics
You can reply to topics
You can delete your posts
You can edit your posts
You can create polls
You can vote in polls
Forum statistics are enabled
Forum is unmoderated

© 2002-2018 Karamasoft LLC. All rights reserved.