Skip to main content

File Upload with Update Panel




ASPX Page
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <Triggers>
                <asp:PostBackTrigger ControlID="Button2" />               
            </Triggers>
            <ContentTemplate>
                <asp:Label ID="Label1" runat="server"></asp:Label>
                <asp:FileUpload ID="fupLogo" runat="server" Visible="False"></asp:FileUpload>
                <asp:Button ID="Button2" runat="server" Text="Upload" OnClick="Button2_Click" Visible="False" />
                <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="show Uploader " />
            </ContentTemplate>
        </asp:UpdatePanel>


Code Behind



protected void Button2_Click(object sender, EventArgs e)
    {
        if (fupLogo.HasFile)
        {
            string fileFormat = fupLogo.PostedFile.ContentType;
            Label1.Text = fupLogo.PostedFile.ContentType;
            if (string.Compare(fileFormat, "image/jpeg", true) == 0 ||
            string.Compare(fileFormat, "image/png", true) == 0 ||
            string.Compare(fileFormat, "image/gif", true) == 0)
            {
                Label1.Text += "file format supported<br/>";
            }
            else
            {
                Label1.Text += "file format not supported<br/>";
            }
        }
        else
        {
            Label1.Text += "file not exist<br/>";
        }
    }
 

Comments

Popular posts from this blog

Tata Punch: A Compact SUV That Packs a Punch

Postback Page using Javascript in ASP.net

Postback Page using Javascript in ASP.net For Calling Function: __doPostBack('__Page', ''); Function: function __doPostBack(eventTarget, eventArgument) {         if (!theForm.onsubmit || (theForm.onsubmit() != false)) {             theForm.__EVENTTARGET.value = eventTarget;             theForm.__EVENTARGUMENT.value = eventArgument;             theForm.submit();         }     }

crystal reports using stored procedures in asp.net

  crystal reports using stored procedures in asp.net   ReportDocument document = new ReportDocument ();         document.Load( this .Page.Server.MapPath( "~/CRY/crTest.rpt" ));         string str = ConfigurationManager .AppSettings[ "ConnectionString" ];         string server = str.Substring(str.IndexOf( "=" ) + 1, str.IndexOf( ";" ) - (str.IndexOf( "=" ) + 1));         str = str.Substring(str.IndexOf( ";" ) + 1);         string database = str.Substring(str.IndexOf( "=" ) + 1, str.IndexOf( ";" ) - (str.IndexOf( "=" ) + 1));         str = str.Substring(str.IndexOf( ";" ) + 1);         string user = str.Substring(str.IndexOf( "=" ) + 1, str.IndexOf( ";" ) - (str.IndexOf( "=" ) + 1));        ...