programming we consider all important topic for knowledge about controls,web Services, JSON, Ajax, database, and interview related Question. In this and sql server tutorial blog we give many examples of jquery as like How Play YouTube Video in Your Website by URL, How to Play YouTube Videos in by using Jquery , Jquery Change div background on mouseover in , JQuery UI Datepicker (Calendar) etc.

Sunday, June 4, 2017

Example FileUpload control

Example FileUpload control:

The form has a FileUpload control along with a save button and a label control for displaying the file name, file type, and file length.
In the design view, the form looks as follows:

The content file code is as given:

   <form id="form1" runat="server">
         <h3> File Upload:</h3>
         <br />
         <asp:FileUpload ID="FileUpload1" runat="server" />
         <br /><br />
         <asp:Button ID="btnsave" runat="server" onclick="btnsave_Click"  Text="Save" style="width:85px" />
         <br /><br />
         <asp:Label ID="lblmessage" runat="server" />

The code behind the save button is as given:

protected void btnsave_Click(object sender, EventArgs e)
   StringBuilder sb = new StringBuilder();
   if (FileUpload1.HasFile)
         sb.AppendFormat(" Uploading file: {0}", FileUpload1.FileName);
         //saving the file
         FileUpload1.SaveAs("<c:\\SaveDirectory>" + FileUpload1.FileName);
         //Showing the file information
         sb.AppendFormat("<br/> Save As: {0}",  FileUpload1.PostedFile.FileName);
         sb.AppendFormat("<br/> File type: {0}",    FileUpload1.PostedFile.ContentType);
         sb.AppendFormat("<br/> File length: {0}",  FileUpload1.PostedFile.ContentLength);
         sb.AppendFormat("<br/> File name: {0}",  FileUpload1.PostedFile.FileName);
      }catch (Exception ex)
         sb.Append("<br/> Error <br/>");
         sb.AppendFormat("Unable to save file <br/> {0}", ex.Message);
      lblmessage.Text = sb.ToString();
} related other post:

·                     Understanding controllers in MVC
·                     Action Method in MVC Controller
·                     Controllers and Action Methods in ASP.NET MVC Appl...
·            Step By Step Working with MVC3
·            with c# example - datetime day of week
·            web Development related Important Post Li...
·                     Why the web.cofig file is very important (The Role...
·                     Validate a date using RangeValidator in c#...
·                     Example of PlaceHolder Server Control
·            PlaceHolder Server Control
·                     C# Coding Conventions (C# Programming Guide)
·                     List of Coding Standard guidelines/checklists for ...
·                     What is the best way to create HTML in C# code
·                     Display Data in HTML Table from Database using Asp...
·                     Templates in DataList Control
·                     Introduction of Datalist Control

·                     How to bind asp datalist control dynamically


  1. Its fantatic explaintion lot of information gather it...nice article....
    seo company in Chennai

  2. Its a wonderful post and very helpful, thanks for all this information. You are including better information regarding this topic in an effective way.Thank you so much

    Installment loans
    Payday loans
    Title loans
    Cash Advances