Unfortunately you can't use another container inside UpdatePanel
to hold the FileUpload
control. But you can do like this:
In the markup:
<asp:ScriptManager runat="server" ID="S"></asp:ScriptManager>
<asp:UpdatePanel runat="server" ID="U" UpdateMode="Conditional">
<ContentTemplate>
<asp:Button runat="server" ID="Btnnew" Text="new" OnClick="Btnnew_Click" />
<asp:FileUpload runat="server" ID="FU" />
<asp:Button runat="server" ID="Btnok" OnClick="Btnok_Click" Text="ok" />
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="Btnok" />
</Triggers>
</asp:UpdatePanel>
And change your code to hide/unhide the contols, and to save the file:
protected void Page_Load(object sender, EventArgs e)
{
Btnnew.Visible = true;
FU.Visible = false;
Btnok.Visible = false;
U.Update();
}
protected void Btnnew_Click(object sender, EventArgs e)
{
Btnnew.Visible = false;
FU.Visible = true;
Btnok.Visible = true;
U.Update();
}
protected void Btnok_Click(object sender, EventArgs e)
{
if (FU.HasFile)
{
string fileName = FU.FileName;
FU.SaveAs(Server.MapPath("~/Images/") + fileName);// Assuming you have Images folder in the root
}
U.Update();
}
You can use <div>
or <table>
and with css make them look like a panel if you wish.