Hi,
I have file upload,button and image control on page.
The below code works in normal asp.net website.
When the file upload is iniside wizard control ,which has update panel ,it does not work.
File upload is inside wizard step 2.
<form id="form1" runat="server" enctype="multipart/form-data"><tr><td><asp:FileUpload ID="fileImage" runat="server" /></td><td><asp:Button ID="btnfileupload" runat="server" CausesValidation="false" CssClass="form_button" OnClick="btnfileupload_Click"
Text="Upload Image" /></td><td><asp:RegularExpressionValidator ID="RevImg" runat="server" ControlToValidate="fileImage"
ErrorMessage="Invalid File!(only .gif, .jpg, .jpeg Files are supported)"
ValidationExpression="^.+(.jpg|.JPG|.gif|.GIF|.jpeg|JPEG)$" ForeColor="Red"></asp:RegularExpressionValidator></td><td><asp:Image ID="imgPhoto" runat="server" Height="165px" Width="165px" Visible="false"
style="margin-left: 0px" /></td></tr>
protected void btnfileupload_Click(object sender, EventArgs e)
{
if (fileImage.HasFile)
{
System.IO.Stream fs = fileImage.PostedFile.InputStream;
System.IO.BinaryReader br = new System.IO.BinaryReader(fs);
Byte[] bytesPhoto = br.ReadBytes((Int32)fs.Length);
string base64String = Convert.ToBase64String(bytesPhoto, 0, bytesPhoto.Length);
imgPhoto.ImageUrl = "data:image/png;base64," + base64String;
imgPhoto.Visible = true;
}
}
<Triggers><asp:PostBackTrigger ControlID="wzEmployeeAdministration$WizardStep2$btnfileupload" /></Triggers>Guhan.