473,563 Members | 2,805 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

System.Web.UI.C ontrol

Guys,

I am trying to run through the page controls, if the controls' id is
found in the database, then I change the corresponding text from the
database. but, the system is coming back with error:

BC30456: 'Text' is not a member of 'System.Web.UI. Control'.

how. I am sure the label control has a text property.

here is my function:

function showControls()
Dim c as control
for each c in page.controls
response.Write( c.ID & "<BR>") <-- this works...
c.Text = "I have been changed" <-- this fails ! why?
testme.Text = "I have been changed"
next
End Function


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitl ed Document</title>
<script language="VB" runat="server">
Sub Page_Load(Sende r as Object, e as EventArgs)
showControls()
End sub
function showControls()
Dim c as control
for each c in page.controls
response.Write( c.ID & "<BR>")
c.Text = "I have been changed"
testme.Text = "I have been changed"
next
End Function
</script>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
</head>

<body>
<asp:label ID="testme" Text="I am here" runat="server"/>
</body>
</html>
Nov 17 '05 #1
2 2876
The System.Web.UI.C ontrol class doesn't have a text property. Classes like
the Label inherit from this and extend it. In order to set the text property
of c you would have to make a cast to the type Label.

You can try something like

if(c.GetType() == "System.Web.UI. WebControls.Lab el")
{
c.Text = "I have changed";
}
Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage

"Tascien" <ta******@ecoac hes.com> wrote in message
news:80******** *************** ***@posting.goo gle.com...
Guys,

I am trying to run through the page controls, if the controls' id is
found in the database, then I change the corresponding text from the
database. but, the system is coming back with error:

BC30456: 'Text' is not a member of 'System.Web.UI. Control'.

how. I am sure the label control has a text property.

here is my function:

function showControls()
Dim c as control
for each c in page.controls
response.Write( c.ID & "<BR>") <-- this works...
c.Text = "I have been changed" <-- this fails ! why?
testme.Text = "I have been changed"
next
End Function


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitl ed Document</title>
<script language="VB" runat="server">
Sub Page_Load(Sende r as Object, e as EventArgs)
showControls()
End sub
function showControls()
Dim c as control
for each c in page.controls
response.Write( c.ID & "<BR>")
c.Text = "I have been changed"
testme.Text = "I have been changed"
next
End Function
</script>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
</head>

<body>
<asp:label ID="testme" Text="I am here" runat="server"/>
</body>
</html>

Nov 17 '05 #2
"Mark Fitzpatrick" <ma******@fitzm e.com> wrote in message
news:#F******** ******@TK2MSFTN GP12.phx.gbl...
The System.Web.UI.C ontrol class doesn't have a text property. Classes like
the Label inherit from this and extend it. In order to set the text property of c you would have to make a cast to the type Label.

You can try something like

if(c.GetType() == "System.Web.UI. WebControls.Lab el")
{
c.Text = "I have changed";
}


How about casting to Label first:

((System.Web.UI .WebControls.La bel) c).Text = "I have changed";

--
John

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3736
by: Greg Bacchus | last post by:
Hi, I'm getting an exception that really has me stumped. It's sporadic at best, it's only happened a handful of times. This particular time it happened when the user pressed 'Alt-S' to save the data that they were entering. Following is all exception information. Any thoughts much appreciated. Cheers
0
9758
by: muralidharan | last post by:
WebForm1.aspx Code: <%@ Register TagPrefix="ComponentArt" Namespace="ComponentArt.Web.UI" Assembly="ComponentArt.Web.UI" %> <ComponentArt:TreeView id="TreeView1" Height="520" AutoPostBackOnNodeMove="false" DragAndDropEnabled="true" NodeEditingEnabled="False" KeyboardEnabled="true" CssClass="TreeView" NodeCssClass="TreeNode"...
3
2439
by: Brano | last post by:
HI all, I have a problem i have a web application that was working fine and this morning when i run it and click on a button that does Reponse.Redirect to a page i get this error : Server Error in '/IPFWEb_6' Application. -------------------------------------------------------------------------------- Object reference not set to an...
4
4475
by: Roger Aikin | last post by:
I've converted a VB6 project to VB.Net 2005. (Actually using vstudio pro 2005). I'm on a machine that also has VB6 and Vstudio.net 2003 on it. The project uses Word, Excel, MapPoint and SqlClient (database is SqlServer 2000). OS is WinXP SP2. When I run the project, it opens the MDI form (MdiMain.vb) fine, but when I open one of the...
0
2203
by: Gursharan | last post by:
Hi, I get this error after I did a load test on my website (500 constant user load in team system for 35 minutes). This error is logged after about 1 minute of load testing and is logged every 60 seconds. Any ideas? Event code: 3005 Event message: An unhandled exception has occurred. Event time: 30/07/2006 21:56:12 Event time (UTC):...
2
14363
by: job | last post by:
In a sharepoint setup using smartpart to load our user controls using enterprise blocks (data) we are getting some strange errors (logged to the event log). We dont get the error all the time. When we get the error CPU goes 100% We have been through all we can think of, but have not been able to locate the source to the error. Any...
3
3991
by: forest demon | last post by:
for example, let's say I do something like, System.Diagnostics.Process.Start("notepad.exe","sample.txt"); if the user does a SaveAs (in notepad), how can i capture the path that the user selects? thanks...
4
1765
by: confused1234 | last post by:
I get the error at the bottom of this post when i click on a linkbutton, javascript:__doPostBack('ctl00$Main$btnchangeemail','') The problem is intermitant, sometimes it works and sometimes it errors, The page is running in an iframe if this makes a difference. ANY IDEAS??? Thanks
2
2490
by: Tom C | last post by:
This error occurs erratically at startup. It appears to be all native code. Does anyone have any idea what the heck could be cauing this? System.ArgumentNullException: Value cannot be null. Parameter name: pen at System.Drawing.Graphics.DrawLine(Pen pen, Int32 x1, Int32 y1, Int32 x2, Int32 y2) at dh.OnPaint(PaintEventArgs e) at...
0
601
by: =?Utf-8?B?TWFyY3VzIFNjaGFlZmVy?= | last post by:
Hi everybody, I'm working on my application for appr. 2 years and now suddenly I got an System.TypeInitializationException in one of my global modules. The error is thrown at the first call of a subroutine out this module. The code I was programming isn't related in any way with this module and I even hadn't loaded this module into the...
0
7665
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
1
7642
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7950
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6255
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5484
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3643
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2082
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.