0

I have a small problem.
I have got a fileupload control inside the update panel.
and when i upload a file in it,it doesnt contains the file.

if(fileupload1.hasfile)
{

}

this statement doesnt get execution. the condition doesnt satisfies.
so i got one solution for it.. Make the fileupload control to do Autopostback.
now to make it autopost back i have to register it.
So i want your help in this case that HOW TO REGISTER FILEUPLOAD CONTROL IN ASP.NET

2
Contributors
1
Reply
3
Views
7 Years
Discussion Span
Last Post by __avd
0

I have a small problem.
I have got a fileupload control inside the update panel.
and when i upload a file in it,it doesnt contains the file.

if(fileupload1.hasfile)
{

}

this statement doesnt get execution. the condition doesnt satisfies.
so i got one solution for it.. Make the fileupload control to do Autopostback.
now to make it autopost back i have to register it.
So i want your help in this case that HOW TO REGISTER FILEUPLOAD CONTROL IN ASP.NET

Select UpdatePanel1 control and set postbacktrigger triggers. (Don't select AsyncPostBack trigger)

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <asp:FileUpload ID="FileUpload1" runat="server" />
            <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
        </ContentTemplate>
        <Triggers>
            <asp:PostBackTrigger ControlID="Button1" />
        </Triggers>
    </asp:UpdatePanel>
protected void Button1_Click(object sender, EventArgs e)
    {
        if (FileUpload1.HasFile)
        {
            FileUpload1.SaveAs(MapPath("~/" + FileUpload1.FileName));
        }
    }
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.