Click here to Skip to main content
15,881,204 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
hii all
i have an input of the type file in html page ,
i want to get this Id and apply the code of upload an image on it.
but, Unfortunately the code doesn't see the control
C#
Control myControl1 = FindControl("FileUpload1");
if (myControl1 != null)
{
}
else
{
    Response.Write("Control not found");
}



HTML
<input type="file" name="FileUpload1" id="FileUpload1" value="FileUpload1" />


any help

thanks
Posted

1 solution

add runat="server" to Input tag and you can access the FileUpload1 from codebehind
 
Share this answer
 
Comments
moon2011 13-Sep-11 6:52am    
how can i put runat="server" from client side control???
it appears an error tells me "The value property on HtmlInputFile is not settable.
"
Herman<T>.Instance 13-Sep-11 6:55am    
<input type="file" name="FileUpload1" id="FileUpload1" value="FileUpload1" runat="server" />

works for me!
BobJanova 13-Sep-11 7:53am    
Read the error message: you can't set the 'value' attribute. I don't see why you're doing that anyway, so just remove it.
Herman<T>.Instance 13-Sep-11 7:57am    
yes you are right
Herman<T>.Instance 13-Sep-11 6:59am    
see http://support.microsoft.com/kb/323246

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900