BC30456: 'text' is not a member of 'System.Web.UI.Control'. Error when trying to assign literal dynamic text

************* Edited by moderator Adec ***************

Inserted missing < code></ code> tags. Always include such
tags when including code in your postings. Don't force the
moderators to do your work. Many readers disregard
postings without the code tags.
**************************************************
Hello All,
Here is a snippet of my code. All i'm doing is looping through a dataset, comparing one of the fields in the dataset with the name of an asp:literal i have in my page and if it maches then
assign the asp:literal some text that i also get from the dataset. When i loop through the web form componets and try to assing the text member a vaule if gives me the error:
BC30456: 'text' is not a member of 'System.Web.UI.Control'.
This erorr is linked to this line:
frmCtrl.text = strDefaultImageLiteral

Here is my code. Please let me know if you can be of any assistance!

while drMapData.read()
For each frmCtrl in me.Controls
If TypeOf frmCtrl Is literal then
if ucase(trim(frmCtrl.id)) = ucase(trim(drMapData("StationHostName"))) then
select case drMapData("StatusID")
case 0
strDefaultImageLiteral = "<img src='images/pcdown01.gif'>"
case 1
strDefaultImageLiteral = "<img src='images/pcavailable01.gif'>"
case 2
strDefaultImageLiteral = "<img src='images/pcinuse01.gif'>"
end select
frmCtrl.text = strDefaultImageLiteral
else
'response.Write(frmCtrl.id & "<>" & drMapData("StationHostName") & "<br>")
end if
end if
Next
End While


0
dorko72
6/26/2004 9:12:51 AM
asp.net.web-forms 93655 articles. 5 followers. Follow

7 Replies
1443 Views

Similar Articles

[PageSpeed] 5

You implicitly declared your control as System.Web.UI.Control (as part of ControlCollection). Control type does not contain text property. Literal control, which subclass Control does. You should cast frmCtrl to literal before assigment.
Leon Langleyben

MCSD, ASP.NET MVP

Blog
0
llangleyben
6/26/2004 11:21:10 AM
Hello, you assign values to a literal as follows:

<asp:Literal id="Literal1" Text="I love ASP!" runat="server" />
Literal1.Text="I love ASP.NET!"

Other than that nothing works, make sure you have something similar to the above two lines.
And, what is that <b>strDefaultImageLiteral</a> ? add to it the Text

regards.
Bilal Hadiar, MCP, MCTS, MCPD, MCT
Microsoft MVP - Telerik MVP
0
haidar_bilal
6/26/2004 11:26:22 AM
Hello All,

Thank you very much for yout suggestions. I figured out the problem. I need to use ctype whe refering to the looping control var like this:
CType(frmCtrl, literal).text= strDefaultImageLiteral
instead of
frmCtrl.text = strDefaultImageLiteral
To be perfectly honest i do not know why this makes a difference. I will need to study the fuction of CType.
Thanks again!
0
dorko72
6/26/2004 2:52:22 PM
Hello, glad u were able to solve the problem. But what I have give u about literals is for non-dynamic literals, but it seems u were using dynamic literals, 

good luck.
Bilal Hadiar, MCP, MCTS, MCPD, MCT
Microsoft MVP - Telerik MVP
0
haidar_bilal
6/26/2004 4:11:17 PM
Use this:

http://www.codeproject.com/dotnet/CheatSheetCastingNET.asp
Good luck!
Leon Langleyben

MCSD, ASP.NET MVP

Blog
0
llangleyben
6/26/2004 7:37:56 PM
Hello, its a good article for our friend, but please do place ur url in < a href="">url< /a > offcourse removing all the spaces. this way it would be better for any one to directly access the url. Thank you.

regards.
Bilal Hadiar, MCP, MCTS, MCPD, MCT
Microsoft MVP - Telerik MVP
0
haidar_bilal
6/26/2004 8:17:20 PM
>>

Thank you very much for yout suggestions. I figured out the problem. I need to use ctype whe refering to the looping control var like this:
CType(frmCtrl, literal).text= strDefaultImageLiteral
instead of
frmCtrl.text = strDefaultImageLiteral
To be perfectly honest i do not know why this makes a difference. I will need to study the fuction of CType.
<<
The reason was metioned previously
>>
You implicitly declared your control as System.Web.UI.Control (as part of ControlCollection). Control type does not contain text property. Literal control, which subclass Control does. You should cast frmCtrl to literal before assigment.
<<

Eric McVicker
0
JOAC
6/27/2004 12:31:55 AM
Reply:

Similar Artilces:

Compiler Error Message: BC30456: 'text' is not a member of 'System.Web.UI.WebControls.DropDownList'.
Hi everyone, This is my first post.  I have always found answers to my questions and have never need to ask one of my own, but I have been stuck on this all morning. Here is whats going on. I created an aspx form on my server running Windows 2000 Advanced server and everything works great.  I created the form using Web Matrix running .net version 1.1.  It is just a form that adds information to a mysql database.  I moved the form to the server which is also running 2000 Advanced Server to the wwwroot folder.  I installed the .net version 1.1.  When I try...

Error: BC30456: 'DataItem' is not a member of 'System.Web.UI.Control'.
I wanted to create a nested DataList with two dataTables.  I followed the steps.   First, set relation to the two datatables in a dataset ds1.Relations.Add("myRelation", ds1.Tables(0).Columns("intMenuItemID"), ds1.Tables(1).Columns("intParentMenu"))     Second, bind the dataset       DataList1.DataSource = ds1.Tables(0).DefaultView       DataList1.DataBind()   Third, add the following to the DataList datasource property       Container.DataItem.Row.GetChildRows("myRelation") &...

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...

BC30456: 'DataItem' is not a member of 'System.Web.UI.Control'.
 I am getting compilation error (bold line): BC30456: 'DataItem' is not a member of 'System.Web.UI.Control'. I am using ASP.NET 2.0 - w/AJAX 2.0 Extension. <asp:UpdatePanel UpdateMode="Always" runat="server">             <ContentTemplate>                   <asp:LinkButton ID="rateit" runat="server" CssClass="vote" Height="56px" Width="63px&...

'Text' is not a member of 'System.Web.UI.WebControls.DropDownList'
Ive got a problem here.I had a script that took user registration info from a form and added it to a database. I had a few issues with relpacing characters and someone gave my some advice on simplifing my script.  Now i am having loads of problems with it.First of all it is now throwing the error above'Text' is not a member of 'System.Web.UI.WebControls.DropDownList'Basically i have a dropdown box with counties in it, oh god this asp.net is killing meSorry code dump:<%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.OleDb" %>  <script language="...

error BC30456: 'CurrentDate' is not a member of 'System.Web.UI.UserControl'
Does anyone know what's causing this error. I got it when I try ro publish this site using .net 2.0. Thanks in advance for your help. Default.aspx:<%@ Page Language="VB" AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="_Default" %>  <%@ Register TagPrefix="GD" TagName="GetDate" Src="GetDate.ascx" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <...

error BC30456: 'DataTable' is not a member of 'System.Web.UI.UserControl'
Help me to solve this eRims\WebErims\WebErims\Common\CommonBrowser.ascx.vb(13,0): error BC30456: 'DataTable' is not a member of 'System.Web.UI.UserControl'.G:\eRims\WebErims\WebErims\Common\CommonBrowser.ascx.vb(16,0): error BC30456: 'DataTable' is not a member of 'System.Web.UI.UserControl'.G:\eRims\WebErims\WebErims\Common\CommonBrowser.ascx.vb(22,0): error BC30456: 'HeaderText' is not a member of 'System.Web.UI.UserControl'.G:\eRims\WebErims\WebErims\Common\CommonBrowser.ascx.vb(25,0): error BC30456: 'HeaderText' is not a member...

Nested repeater and BC30456: 'DataItem' is not a member of 'System.Web.UI.Control'.
I've got an application where I can make use a nested repeater... I found this Microsoft How To: http://support.microsoft.com/kb/326338/EN-US and attempted to copy that code, but I'm stuck getting the error in the subject. As far as I can tell, my code is all good but for whatever reason it's just not working the way it should. I've posted the code and code-behind pages below, if you have any thoughts on what I can do to fix this please let me know! The line that brings up the compilation error is: <asp:Repeater ID="childRepeater" Runat="server" DataSource='<...

'DataItem' is not a member of 'System.Web.UI.Control'
I was going through the "WEb Matrix Guided Tour" and ran across the following error when I tried to do the section "ASP.NET Pages with Data (SQL Server/MSDE) DataList and Templates". I went through it three times and can not get past this point. Any suggestions would be appreciated. PS: Rookie to this, so please be kind!!! Server Error in '/' Application. -------------------------------------------------------------------------------- Compilation Error Description: An error occurred during the compilation of a resource required to service this requ...

'DataItem' is not a member of 'System.Web.UI.Control'
Hi I am getting this error on my attempt at a repeater control. Any help would be appreciated. This is the code for the HTML <asp:Repeater id="rptTests" runat="server"></asp:Repeater> <ITEMTEMPLATE> <tr style="BACKGROUND-COLOR: #ffecd8"> <td> <%# DataBinder.Eval(Container.DataItem, "test") %> </td> </tr> </ITEMTEMPLATE> This is the cod...

Error Message CS0117: 'System.Web.UI.WebControls.DropDownList' does not contain a definition for 'Text'
I get this Error Message: ( CS0117: 'System.Web.UI.WebControls.DropDownList' does not contain a definition for 'Text' ) from my Register.aspx when I try to open it. I've added a DropDownList to the Register.aspx page and it throws me this (CS0117 Error message). Could use some help on this. Don't know where and how to correct this problem. If I remove the Dropdownlist and recompile the CustomersDB.cs file, and run the Register.aspx page again then it opens up. But as soon as I add the DropdownList I receive this (Error CS0117). Would appreciate any help. Thank You. TIA. Here is the co...

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>    ...

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...

Error: 'DataBinder' is not a member of 'System.Web.UI.DataBinder'.
I'm getting the following error trying to compile.  'DataBinder' is not a member of 'System.Web.UI.DataBinder'. It points this line of code <%# DataBinder.Eval(Container, "DataItem.STORE_NO")%>   I'm creating a VB module for DotNetNuke if this might help.   Thanks,  Erick   What happens when you remove DataBinder.?Community Coder Also, what type of control are you trying to bind data to?  Community Coder jamesqua: What happens when you remove DataBinder.? Now I get this error:Error 69 Value...

Web resources about - BC30456: 'text' is not a member of 'System.Web.UI.Control'. Error when trying to assign literal dynamic text - asp.net.web-forms

Resources last updated: 12/14/2015 2:29:18 AM