473,406 Members | 2,345 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,406 software developers and data experts.

How to disable a Control dynamically

Dear All,

I have about 31 ASP.TextBox controls on my WebForm. The name pattern of
the TextBox are as follows:
"TextBox1", "TextBox2"...."TexBox31".

I want to disable some of them dynamically. I have done the same in ASP.
But, i don't know how to in ASP.NET. Following are my code which done
in ASP:

For i = 1 to 31
mTextBox = "TextBox" & ltrim(str(i))
mTextBox.enabled = false
Next i

above is just like to show u an example. How can I implement the above
in ASP.NET.

Appreciate your help..

Rgds-

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 21 '05 #1
2 4734
You can use the FindControl method on the Page to find the control with the
given name. You could then set the Enabled property to false.

Dim tb As TextBox
For i = 1 To 31
tb = DirectCast( FindControl( "TextBox" & I ), TextBox )
tb.Enabled = false
Next

- Paul Alexander

"Ahmed Jewahar" <aj******@sa.dhl.com> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
Dear All,

I have about 31 ASP.TextBox controls on my WebForm. The name pattern of
the TextBox are as follows:
"TextBox1", "TextBox2"...."TexBox31".

I want to disable some of them dynamically. I have done the same in ASP.
But, i don't know how to in ASP.NET. Following are my code which done
in ASP:

For i = 1 to 31
mTextBox = "TextBox" & ltrim(str(i))
mTextBox.enabled = false
Next i

above is just like to show u an example. How can I implement the above
in ASP.NET.

Appreciate your help..

Rgds-

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Jul 21 '05 #2
Paul,

Thank you very much for your help.. I will btr tryin your code today.

I have one more question and hope that you can solve this as well.

In the Webform I have One Server Control (Image). This control has been
hided on PageLoad event. "Image1.Visibile = False"

Also I have one command button on the same WebForm. Onclick event of
this command button, at the first line of the Sub I put the following to
make "Image1" visibile to user: "Image1.Visible = True". After this line
I have set of process that will take about 2 min. to complete.

The problem is that "Image1" is not visible to user until system
complete the whole process which is written in "Onclick" event of the
command button. Any idea on as how to resolve this.

Apprecite your help..

Regards,

Ahmed

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 21 '05 #3

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

Similar topics

6
by: GD | last post by:
Hi, I wonder how to disable the "submit" behavior of a button. What I want is to assign values to dynamically added user controls without page postback. Problem: dynamically created control can...
2
by: Fluxray | last post by:
--Background: I have a webform including a datagrid. The datagrid is using template. Its ItemTemplate is used to display a look-up-table with labels. its EditItemTemplate is used to edit a row in...
13
by: Rich | last post by:
Hello, So I would like to disable a textbox on a vb.net form without the text getting grayed out. In vb6 I could place a textbox control on a frame control and disable the frame leaving the...
2
by: Ahmed Jewahar | last post by:
Dear All, I have about 31 ASP.TextBox controls on my WebForm. The name pattern of the TextBox are as follows: "TextBox1", "TextBox2"...."TexBox31". I want to disable some of them dynamically....
9
by: SlimFlem | last post by:
Is this possible? My entire web site is being built dynamically using WebPart's and a lot of it will be anonymous. How do I load these parts dynamically using WebPartManager.AddWebPart() and not...
5
by: misiek | last post by:
Hi all. I would like to know if it is possible to dynamically enable/disable row editing in GridView control in ASP.NET 2.0. I am asking because this feature should be enabled/disable depending...
4
by: kschneider | last post by:
Assume there's a form with it's action attribute all set to post to a URL, but without a submit control. Form submission is done via a link and I want to prevent the classic "double submit"....
2
by: rn5a | last post by:
In a shopping cart app, assume that a user has placed 4 orders (each order has a corresponding OrderID which will be unique). When he comes to MyCart.aspx, by default, the details of his last order...
5
by: masterej | last post by:
Developers, Is there any way to disable all checkboxes on a form? I have a form with 160 checkboxes and I want to be able to disable all of them. Is there a way I can do something like this: ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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,...
0
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...

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.