Cannot convert type 'System.Web.UI.Control' to 'FileUpload'

Hi,


I'm getting an error in the follow code:

FileUpload fileUpload1 = (FileUpload)itemPanel.FindControl("fuDoc");

Where itemPanel is a AjaxControlToolkit.TabPanel and the aspx code is: <asp:FileUpload ID="fuDocument_es" runat="server" />

The error is Cannot convert type 'System.Web.UI.Control' to 'FileUpload'

 Why?

 

Thanks

0
enriquevald
4/3/2009 5:57:55 PM
asp.net.web-forms 93655 articles. 6 followers. Follow

1 Replies
1822 Views

Similar Articles

[PageSpeed] 56

You are trying to find and convert "fuDoc" or "fuDocument_es"  ?

try this

FileUpload fileUpload1 = (FileUpload)itemPanel.FindControl("fuDocument_es");

0
Dil
4/3/2009 6:13:53 PM
Reply:

Similar Artilces:

ASPNET2 HELP! CS0266: Cannot implicitly convert type 'System.Web.UI.Control' to 'System.Web.UI.WebControls.FileUpload'.
Server Error in '/start-movieposters' Application. Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. Compiler Error Message: CS0266: Cannot implicitly convert type 'System.Web.UI.Control' to 'System.Web.UI.WebControls.FileUpload'. An explicit conversion exists (are you missing a cast?) Source Error: ...

Error: Cannot convert type 'System.Web.UI.Control' to 'System.Web.UI.WebControls.ButtonField'
Hello, I am getting the following error during compiliation. Any suggestions to fix it. Thanks. Cannot convert type 'System.Web.UI.Control' to 'System.Web.UI.WebControls.ButtonField' protected void gvEvents_RowCommand(Object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Select") { int index = Convert.ToInt32(e.CommandArgument); GridViewRow selectedRow = gvEvents.Rows[index]; string sID; ButtonField btn; if (selectedRow.RowType == DataControlRowType.DataRow) { sID = ((ButtonField)selectedRow.FindControl("ID")).DataTextFi...

Value of type 'System.Web.UI.Control' cannot be converted to 'System.Web.SiteMap'.
 Hello,         I receive this error "System.Web.UI.Control' cannot be converted to 'System.Web.SiteMap" when I try to find the Sitemap control.  ...            <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />            <asp:ListView ID="ListView1" runat="server">            <LayoutTemplate>    ...

Unable to cast object of type 'System.Web.UI.LiteralControl' to type 'System.Web.UI.WebControls.TextBox'
Hello, Goal: enter a number in two fields HoursPerUnit and PeoplePerUnit and the value for the third field, TotalHoursPerUnit will populate after the the number in the two fields have been caculated.  Using the code below I receive the error message above.  Please tell me what am I doing wrong? Do I need to cast the text as a literal?  Please help? Thank you in advance, <%@ Page Language="VB" MasterPageFile="Default.master" AutoEventWireup="false" CodeFile="frmHR.aspx.vb" Inherits="frmHR"...

Unable to cast object of type 'System.Web.UI.LiteralControl' to type 'System.Web.UI.WebControls.TextBox'.
Hi, any idea why I'm getting the following error?Line 45: protected void CartGrid_RowUpdating(object sender, System.Web.UI.WebControls.GridViewUpdateEventArgs e) Line 46: { Line 47: TextBox QuantityTextBox = (TextBox)CartGrid.Rows[e.RowIndex].Cells[2].Controls[0]; Line 48: int Quantity = Convert.ToInt32(QuantityTextBox.Text); Line 49: Are you sure that the control at CartGrid.Rows[e.RowIndex].Cells[2].Controls[0] isn't a LiteralControl?  How are you creating code this in your code?Brent JenkinsASP.NET, C#, Web Developerwww.valewebdesign.co.uk  ...

Unable to cast object of type 'System.Web.UI.WebControls.FormView' to type 'System.Web.UI.WebControls.DropDownList'.
Hi,  I have a formview with a dropdownlist created dynamically. i want to determine whether the dropdownlist was clicked. the code is written in the FormView1_DataBound method. I get the following error in the line below that is in italics and underlined: Unable to cast object of type 'System.Web.UI.WebControls.FormView' to type 'System.Web.UI.WebControls.DropDownList'.   Here is my code: ddl_iFullname = New DropDownList ddl_iFullname.ID = "ddl_iFullname" ddl_iFullname.DataSource = ObjectDataSource3 ddl_iFullname.DataTextField = "fullname" ddl_iFullname.DataValueField = "...

Unable to cast object of type 'System.Web.UI.WebControls.Label' to type 'System.Web.UI.WebControls.TextBox'
I am attempting to "Update" a field in a Datagrid, but no matter what I do (Using either Label or Text Boxes)  I keep getting the same error: Unable to cast object of type 'System.Web.UI.WebControls.Label' to type 'System.Web.UI.WebControls.TextBox' The Error is highlighted below in the Sub... <==THE FIELD THAT CALLS THE ERROR  Any help would be greatly appreciated !!! Thanks !!   The code is as follows... <table border=0 height=210 bordercolor=olive ><tr valign=top><td> <asp:datagrid id="FacilityDataGrid"...

BC30311: Value of type 'Control' cannot be converted to 'System.Web.UI.WebControls.CheckBox'
 Hi, can somebody help me on this problem. It works at first, but all of a sudden, it fails, and I can't find out why.    1 Sub btnSave_Click(ByVal sender As Object, ByVal e As EventArgs) 2 3 If Not CheckRequiredField() Then 4 MessageBox("Please complete the input data!") 5 Exit Sub 6 End If 7 8 Dim nRow As Integer 9 Dim Ctrl As Control 10 Dim chkDelete As Object 11 Dim LookupID, Name, Desc, Type As String 12 13 nRow = 0 14 1...

'System.Web.UI.Control' cannot be converted to 'String'.
I am trying to run a simple Edit, Update, Delete. I found a simple example in a book I've got. My only concern is withing the string it's first Declaration is Read only, so it won't be edited. and for some reason I am getting this error: The update function that is right after the page_load is giving me the problems. Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. Compiler Error Message: BC30311: Value of type 'Sy...

cannot convert from 'archive_class' to 'System.Web.UI.Control' ??
 i created this class and it takes 2 parameters and then i call that class and pass the parameters and add it to a palceholder control it should create a div tag and add an id and text in it .public archive_class(string DivID,string sText) {HtmlGenericControl div1 = new HtmlGenericControl("div"); div1.InnerText = sText; div1.ID = DivID;return; }   and i call the object here  protected void Page_Load(object sender, EventArgs e) {archive_class arch = new archive_class("someID","someText"); PlaceHolder1.Controls.Add(arch); }   ...

Error Serializing Value 'System.Web.UI.WebCOntrols.TreeNode' of type 'System.Web.UI.WebCOntrols.TreeNode'
Hi, I am  getting the error stated in the subject when i am storing a TreeNode in a ViewState and then using it as follows if (ViewState["ProductCounty"]!=null) { TreeNode _productCountyNode = DataTree.FindNode(((TreeNode)ViewState["ProductCounty"]).ValuePath); _productCountyNode.Expand(); } what could be causing this error? Hi, I believe TreeNode isn't serializable in a way its required for objects which can be put to ViewState - as reference - (TreeNode implements IStateManager and is meant to work together with TreeView itself saving it...

Extender controls of type 'AjaxControlToolkit.DragPanelExtender' cannot extend controls of type 'System.Web.UI.HtmlControls.HtmlGenericControl'.
Hi, I'm getting this error when trying to port an old Atlas Web App to use the latest bits - any help would be nice as to what controls I CAN extend - so if I can't use a DIV what then?: Server Error in '/GRintranets' Application. Extender control 'DragPanelExtender1' cannot extend 'divPaginaHTML'. Extender controls of type 'AjaxControlToolkit.DragPanelExtender' cannot extend controls of type 'System.Web.UI.HtmlControls.HtmlGenericControl'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more informati...

Compiler Error Message: BC30311: Value of type 'System.Web.UI.Control' cannot be converted to 'IWizardStep'.
I am working with a Book ASPNET 2.0 Unleashed "by the way, great book". There code is witten with <script> tags and the vb is in the same page as the Html. So, as practice, I am simply trying to convert it to code behind... The page calls a class named "IWizardSetp" See both there code and my convered code below. I get the following error. What am I doing wrong? Details please if you can help... Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details a...

Error 1 The type 'System.Web.UI.WebControls.LinqDataSource' exists in both 'c:\WINDOWS\assembly\GAC_MSIL\System.Web.Extensions\3.5.0.0__31bf3856ad364e35\System.Web.Extensions.dll' and 'c:\WINDOWS\asse
Once I build project. I encounter this error. Does someone experience this error?Error    1    The type 'System.Web.UI.WebControls.LinqDataSource' exists in both 'c:\WINDOWS\assembly\GAC_MSIL\System.Web.Extensions\3.5.0.0__31bf3856ad364e35\System.Web.Extensions.dll' and 'c:\WINDOWS\assembly\GAC_MSIL\System.Web.Extensions\3.6.0.0__31bf3856ad364e35\System.Web.Extensions.dll'    D:\Source Code\Linq_Lesson5\Default.aspx    1    1    D:\Source Code\Linq_Lesson5\  It appears tha...

Web resources about - Cannot convert type 'System.Web.UI.Control' to 'FileUpload' - asp.net.web-forms

Resources last updated: 12/21/2015 11:19:45 PM