473,320 Members | 2,029 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

System.Web.UI.Control

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>Untitled Document</title>
<script language="VB" runat="server">
Sub Page_Load(Sender 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 2863
The System.Web.UI.Control 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.Label")
{
c.Text = "I have changed";
}
Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage

"Tascien" <ta******@ecoaches.com> wrote in message
news:80**************************@posting.google.c om...
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>Untitled Document</title>
<script language="VB" runat="server">
Sub Page_Load(Sender 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******@fitzme.com> wrote in message
news:#F**************@TK2MSFTNGP12.phx.gbl...
The System.Web.UI.Control 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.Label")
{
c.Text = "I have changed";
}


How about casting to Label first:

((System.Web.UI.WebControls.Label) 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
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...
0
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"...
3
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...
4
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...
0
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...
2
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...
3
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...
4
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...
2
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....
0
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.