asp.net - How to use Fileupload control in UpdatePanel? -
i have fileupload
, image
control , button
control. using updatepanel
: when click button after chosing image, image
control should show image without postback. not work?
<asp:scriptmanager id="scriptmanager1" runat="server"></asp:scriptmanager> <asp:updatepanel id="updatepanel1" runat="server"> <contenttemplate> <asp:fileupload id="fileupload1" runat="server" /> <br /> <asp:image id="image1" runat="server" /> </contenttemplate> <triggers> <asp:asyncpostbacktrigger controlid="button1" /> </triggers> </asp:updatepanel> <asp:button id="button1" runat="server" text="button" onclick="button1_click" />
my code behind just:
protected void button1_click(object sender, eventargs e) { if (fileupload1.hasfile) { fileupload1.saveas(server.mappath("~/") + fileupload1.postedfile.filename); image1.imageurl = "~/" + fileupload1.postedfile.filename; } }
how can ?
Comments
Post a Comment