Technological Guide.

ASP.Net FileUpload control inside Ajax UpdatePanel

Wednesday, May 18th, 2011

I’m posting this article with reference to the request from my friends and for all other world wide asp.net lovers and especially for programmers who are in need of a solution for asp.net FileUpload control inside Ajax UpdatePanel. We often face problem with FileUpload control when its placed inside Ajax UpdatePanel. There is a simple trick for it to make it upload without any issues :).

ASP.Net FileUpload control needs a full Page PostBack to upload file and proceed further. The simplest solution to use UpdatePanel is by adding PostBackTrigger to the updatepanel as shown below.

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
        Please upload your file: <br />
        <asp:FileUpload ID="FileUpload1" runat="server" />&nbsp;&nbsp;
        <asp:Button runat="server" ID="btnSubmit" Text="Upload"
            onclick="btnSubmit_Click" />
        <br />
        <asp:Label runat="server" ID="lblFileDetails" Text=""></asp:Label>
    </ContentTemplate>
    <Triggers>
        <asp:PostBackTrigger ControlID="btnSubmit" />
    </Triggers>
</asp:UpdatePanel>

I’m presenting you a simple example with both HTML source code and C# code behind files which is coded for Microsoft .Net Framework 3.5 (Visual Studio 2008).

You can download from: FileUploadInsideUpdatePanel

C#2008 How to show images in ListView from Database

Thursday, August 13th, 2009

Being programmers you may get requirement to handle with images to save to database and load them into ListView container. I’m presenting a code snippet in Visual C# 2008 which can be downloaded and can be tested on your end for the ListView items with images retrieved and updated back to the database.

Features:

  • Allows to select image using OpenDialog.
  • You can save to database which will be an Access 2003 mdb file located in \bin\Debug folder.
  • You can retrieve images using Retrieve Images button.
  • You can remove image using Remove button which will remove image from database directly.

Requirements:

  • Visual C# 2008 with Microsoft .Net Framework 3.5

You can download from ListViewImgDb and use the rar file using the password: lsv123

Color Selector

Wednesday, June 24th, 2009
Color Selector is a small application developed in Visual C# which displays all named color along with a small strip of the color. Upon selecting the color the below panel will be updated with the selected color. As shown in the 2 images.

The DrawItem event of the combo box control has to be implemented in the code and DrawMode property for the combo box control must be set to OwnerDrawFixed in design time in order to let the DrawItem event work.

Design & Coding Application:

Create a Visual C# Windows Forms project in either Visual Studio 2005 / 2008 with Single Form which contains a button (btnLoadColorList), combo box(cmbColorList) and panel (pnlColorTester). Set the DrawMode property of cmbColorList to OwnerDrawFixed and DropDown height property of cmbColorList to 80.

Code for the Form will be as follows.

You can download the sample application developed in Visual Studio 2008 from here.