473,382 Members | 1,407 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,382 software developers and data experts.

need help writing to a control

If i create a textbox tb1,
I can write to it as such:

tb1.Text = "mytext";

I can make it visible:
tb1.Visible = true;

or invisible:
tb1.Visible = false;

Thanks to a posting here from a previous
question, I can reference that control
indirectly to set it visible:

string st1;

st1 = "tb1";

FindControl(st1).Visible = true;

But, this doesn't work:

FindControl(st1).Text = "mytext";

Is there a way to set the text of a control in an indirect
way?

thanks,

Robert
Nov 16 '05 #1
2 905
Visible is inherited from Control and since FindControl returns a Control,
you can use the Visible property.

Text, on the other hand, is a TextBox property, not inherited from Control
so you have to cast your Control as a TextBox to see Text:

((TextBox) FindControl(st1)).Text = "mytext";

DalePres
MCAD, MCDBA, MCSE
"Robert Megee" <rm*****@comcast.net> wrote in message
news:cb********************************@4ax.com...
If i create a textbox tb1,
I can write to it as such:

tb1.Text = "mytext";

I can make it visible:
tb1.Visible = true;

or invisible:
tb1.Visible = false;

Thanks to a posting here from a previous
question, I can reference that control
indirectly to set it visible:

string st1;

st1 = "tb1";

FindControl(st1).Visible = true;

But, this doesn't work:

FindControl(st1).Text = "mytext";

Is there a way to set the text of a control in an indirect
way?

thanks,

Robert

Nov 16 '05 #2
Great! I'll give it a try!

Thanks!

Robert
On Wed, 16 Mar 2005 18:24:07 -0600, "DalePres"
<don-t-spa-m-me@lea-ve-me-a-lone--.com> wrote:
Visible is inherited from Control and since FindControl returns a Control,
you can use the Visible property.

Text, on the other hand, is a TextBox property, not inherited from Control
so you have to cast your Control as a TextBox to see Text:

((TextBox) FindControl(st1)).Text = "mytext";

DalePres
MCAD, MCDBA, MCSE
"Robert Megee" <rm*****@comcast.net> wrote in message
news:cb********************************@4ax.com.. .
If i create a textbox tb1,
I can write to it as such:

tb1.Text = "mytext";

I can make it visible:
tb1.Visible = true;

or invisible:
tb1.Visible = false;

Thanks to a posting here from a previous
question, I can reference that control
indirectly to set it visible:

string st1;

st1 = "tb1";

FindControl(st1).Visible = true;

But, this doesn't work:

FindControl(st1).Text = "mytext";

Is there a way to set the text of a control in an indirect
way?

thanks,

Robert


Nov 16 '05 #3

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

Similar topics

7
by: Steve Menard | last post by:
Here is my problem. I have this library thats hosts another language within python, and allows that language to call back INTO python. All is good as long as the other languages calls back on...
19
by: James Fortune | last post by:
I have a lot of respect for David Fenton and Allen Browne, but I don't understand why people who know how to write code to completely replace a front end do not write something that will automate...
2
by: Billy | last post by:
Hello, I'm trying to decide if I need Visual Studio .Net or if VB .NET will suffice. I've read the guide at http://msdn.microsoft.com/vbasic/howtobuy/choosing.aspX but still have a few...
40
by: apprentice | last post by:
Hello, I'm writing an class library that I imagine people from different countries might be interested in using, so I'm considering what needs to be provided to support foreign languages,...
8
by: BJ | last post by:
Problem: How can I code up a client side process to detect if the network is available? Synopsis: I am writing ASP.NET input forms for a Panasonic Tuff book. The users will be walking around...
2
by: engwar1 | last post by:
I'm a .Net newbie and have started writing a Windows Forms application to assist me in choosing files/directories to move from one drive to another. Basically what I want is something like the...
2
by: | last post by:
I want to use codebehind to pass property values to a control that I've embedded INSIDE of a user control. In other words, let's say I have the following: MyPage.aspx ....with the following...
6
by: squishy | last post by:
I tried to hire programmers to do some stuff, but cannot find reliable, intelligent C++ Gurus (at Guru or RentACoder at least). So I am stuck learning C++ and doing the jobs myself. I would...
4
by: Claire | last post by:
Hi, Im new at user control writing in dotnet. I've written a simple gradient painted panel control based on the UserControl class. It works reasonably, but the properties arent being persisted....
2
by: redfog | last post by:
I need help writing some code for this procedure: Inventory – Add to Item Listing menu item (15 points). Application users will use this menu as part of the process of entering inventory...
1
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: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.