Click here to Skip to main content
15,885,435 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Open files from listbox file listing in c# Pin
Member 120161061-Oct-15 20:42
Member 120161061-Oct-15 20:42 
GeneralRe: Open files from listbox file listing in c# Pin
Wendelius1-Oct-15 21:02
mentorWendelius1-Oct-15 21:02 
GeneralRe: Open files from listbox file listing in c# Pin
Member 120161061-Oct-15 21:14
Member 120161061-Oct-15 21:14 
QuestionApp_GlobalResources and resx files, cannot find appropriate culture Pin
jkirkerx1-Oct-15 9:34
professionaljkirkerx1-Oct-15 9:34 
Answer[Solved] Re: App_GlobalResources and resx files, cannot find appropriate culture, masterpage Pin
jkirkerx1-Oct-15 13:50
professionaljkirkerx1-Oct-15 13:50 
Questionstart date end date not working Pin
Ekrem Tapan30-Sep-15 23:43
Ekrem Tapan30-Sep-15 23:43 
AnswerRe: start date end date not working Pin
Wendelius1-Oct-15 8:40
mentorWendelius1-Oct-15 8:40 
QuestionI wanted to upload Multiple Files With ListBox in ASP.NET Pin
Member 1201610630-Sep-15 16:33
Member 1201610630-Sep-15 16:33 
I wanted to upload Multiple Files With ListBox in ASP.NET but there is an error at specific place....
The error on :
File.Add(FileUpload1);
It showing error on 'File.Add'

asp:
XML
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
            <asp:FileUpload ID="FileUpload1" runat="server" AllowMultiple="true" style="z-index: 1; left: 420px; top: 315px; position: absolute; width: 285px; height: 22px" />
            <asp:Button ID="btnUpload" Text="Add" runat="server" OnClick ="UploadMultipleFiles" accept ="image/gif, image/jpeg, application/exe" style="z-index: 1; left: 425px; top: 535px; position: absolute" />
            <hr />
            <asp:Label ID="lbl_text" runat="server" ForeColor ="Red" style="z-index: 1; left: 701px; top: 495px; position: absolute" />
           <asp:ListBox ID="ListBox1" runat="server"  style="z-index: 1; left: 415px; top: 371px; position: absolute; width: 280px; height: 147px; margin-left: 3px; margin-top: 0px"></asp:ListBox>
        <asp:Button ID="btn_remove" runat="server" OnClick="btn_remove_Click" style="z-index: 1; left: 500px; top: 535px; position: absolute" Text="Remove" />


c#:
C#
///<link to upload button>
        protected void UploadMultipleFiles(object sender, EventArgs e)
        {
            try
            {
                if (FileUpload1.HasFile)
                {
                    if (FileUpload1.PostedFile.ContentLength > 0)
                    {
                        if (ListBox1.Items.Contains(new ListItem(System.IO.Path.GetFileName(FileUpload1.PostedFile.FileName))))
                        {
                            lbl_text.Text = "File already in the ListBox";
                        }
                        else
                        {
                            File.Add(FileUpload1);
                            ListBox1.Items.Add(System.IO.Path.GetFileName(FileUpload1.PostedFile.FileName));
                            lbl_text.Text = "Add another file or click Upload to save them all";
                        }
                    }
                    else
                    {
                        lbl_text.Text = "File size cannot be 0";
                    }
                }
                else
                {
                    lbl_text.Text = "Please select a file to add";
                }
            }
            catch (Exception ex)
            {
            }
        }
        ///</link>
///<link to remove button>
        protected void btn_remove_Click(object sender, EventArgs e)
        {
            if (ListBox1.Items.Count > 0)
        {
            if (ListBox1.SelectedIndex < 0)
            {
               Label1.Text = "Please select a file to remove";
            }
            else
            {
                File.RemoveAt(ListBox1.SelectedIndex);
                ListBox1.Items.Remove(ListBox1.SelectedItem.Text);
                lbl_text.Text = "File removed";
            }
       }
    }
        ///</link>

AnswerRe: I wanted to upload Multiple Files With ListBox in ASP.NET Pin
aarif moh shaikh1-Oct-15 0:29
professionalaarif moh shaikh1-Oct-15 0:29 
GeneralRe: I wanted to upload Multiple Files With ListBox in ASP.NET Pin
Member 120161061-Oct-15 17:12
Member 120161061-Oct-15 17:12 
GeneralRe: I wanted to upload Multiple Files With ListBox in ASP.NET Pin
Member 120161061-Oct-15 17:23
Member 120161061-Oct-15 17:23 
QuestionDisplay Image from MSSQL database into asp.net page using vb Pin
caffrey_130-Sep-15 4:52
caffrey_130-Sep-15 4:52 
AnswerRe: Display Image from MSSQL database into asp.net page using vb Pin
Wendelius30-Sep-15 5:01
mentorWendelius30-Sep-15 5:01 
GeneralRe: Display Image from MSSQL database into asp.net page using vb Pin
caffrey_130-Sep-15 5:18
caffrey_130-Sep-15 5:18 
GeneralRe: Display Image from MSSQL database into asp.net page using vb Pin
caffrey_130-Sep-15 20:48
caffrey_130-Sep-15 20:48 
GeneralRe: Display Image from MSSQL database into asp.net page using vb Pin
Wendelius1-Oct-15 8:34
mentorWendelius1-Oct-15 8:34 
QuestionI'm working on upload exe file in c# Pin
Member 1201610630-Sep-15 0:04
Member 1201610630-Sep-15 0:04 
AnswerRe: I'm working on upload exe file in c# Pin
Richard Deeming30-Sep-15 2:37
mveRichard Deeming30-Sep-15 2:37 
GeneralRe: I'm working on upload exe file in c# Pin
Member 1201610630-Sep-15 4:17
Member 1201610630-Sep-15 4:17 
QuestionHow to display image in a treeview from database Pin
Zahid Hayat29-Sep-15 21:41
Zahid Hayat29-Sep-15 21:41 
AnswerRe: How to display image in a treeview from database Pin
Blikkies29-Sep-15 22:55
professionalBlikkies29-Sep-15 22:55 
GeneralRe: How to display image in a treeview from database Pin
Zahid Hayat30-Sep-15 2:56
Zahid Hayat30-Sep-15 2:56 
Questionhow to highlight the search result in datagridview using c#. Pin
Member 1201610628-Sep-15 0:15
Member 1201610628-Sep-15 0:15 
AnswerRe: how to highlight the search result in datagridview using c#. Pin
taleebanwar28-Sep-15 21:54
taleebanwar28-Sep-15 21:54 
GeneralRe: how to highlight the search result in datagridview using c#. Pin
Member 1201610630-Sep-15 15:27
Member 1201610630-Sep-15 15:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.