I have html control as fileuploader
and i add runat="server"
to it to access it at server side, I don't want to user asp:FileUploader
because of its bad css
style especially in bootstrap
<span>
<input type="file" runat="server" id="File_Upload" />
</span>
Now i need to get image from this html fileUploder
to save it in database
I got example code from google to get image from fileuploader
as
Byte[] imgbyte = null;
if (File_Upload.PostedFile != null)
{
HttpPostedFile file = File_Upload.PostedFile;
imgbyte = new Byte[file.ContentLength];
file.InputStream.Read(imgbyte, 0, file.ContentLength);
}
but when i examine by using breakpoint
then compiler does not enter into IF
body because of Null
vaule
I also used this
ScriptManager.GetCurrent(this).RegisterPostBackControl(this.File_Upload);
in Form_Load
Event due to using asp:UpdatePanel
but i didn't get file (Image) from FileUploader
I need your help to solve this issue..
Thanks in advance.
EDIT:
When i remove asp:UpdatePanel
then i can access file that i select.
and also use
<Triggers>
<asp:PostBackTrigger ControlID="File_Upload" />
</Triggers>
Solution:
Mistakenly i used FileUploader's ID and by following @Suprabhat's suggestion i change it as
<Triggers>
<asp:PostBackTrigger ControlID="btnCreate" />
</Triggers>
and now working fine..