Is it possible to iterate through all the controls collection and make the
textboxes alone as read only.I don't see a readonly property for the
Control.Can some one help me in this context?
I want to do something like this below.But I get a message Readonly is not
valid property.
foreach (Control ctl in pnlBenefits.Con trols)
{
if (ctl is TextBox)
ctl.ReadOnly=fa lse;
} 10 7259
I believe what you are after is:
..GetType()
--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"GP" <GP@discussions .microsoft.com> wrote in message
news:C0******** *************** ***********@mic rosoft.com... Is it possible to iterate through all the controls collection and make the textboxes alone as read only.I don't see a readonly property for the Control.Can some one help me in this context? I want to do something like this below.But I get a message Readonly is not valid property. foreach (Control ctl in pnlBenefits.Con trols) { if (ctl is TextBox) ctl.ReadOnly=fa lse; }
why dont you do a explicit typecast and then get its readonly property
foreach (Control ctl in pnlBenefits.Con trols)
{
if (ctl is TextBox)
{
((TextBox)ctl). ReadOnly = false;
}
}
i think this should do the job
--
Regards,
Hermit Dave
( http://hdave.blogspot.com)
"GP" <GP@discussions .microsoft.com> wrote in message
news:C0******** *************** ***********@mic rosoft.com... Is it possible to iterate through all the controls collection and make the textboxes alone as read only.I don't see a readonly property for the Control.Can some one help me in this context? I want to do something like this below.But I get a message Readonly is not valid property. foreach (Control ctl in pnlBenefits.Con trols) { if (ctl is TextBox) ctl.ReadOnly=fa lse; }
"GP" <GP@discussions .microsoft.com> wrote in message
news:C0******** *************** ***********@mic rosoft.com... Is it possible to iterate through all the controls collection and make the textboxes alone as read only.I don't see a readonly property for the Control.Can some one help me in this context? I want to do something like this below.But I get a message Readonly is not valid property.
foreach (Control ctl in pnlBenefits.Con trols)
{
if (ctl is TextBox)
{
TextBox txt = (TextBox) ctl;
txt.ReadOnly=fa lse;
}
}
-----
John Saunders
Hi Hermit Dave,
Thanks for you response.
This time it didn't error me out, but none of my text boxes is set to
readonly.
My text boxes are declared using System.Web.UI.W ebControls.Text Box,Is it
considered of Type TextBox too while using the Controls iteration.
Thanks
GP
"Hermit Dave" wrote: why dont you do a explicit typecast and then get its readonly property foreach (Control ctl in pnlBenefits.Con trols) { if (ctl is TextBox) { ((TextBox)ctl). ReadOnly = false; } }
i think this should do the job --
Regards,
Hermit Dave (http://hdave.blogspot.com) "GP" <GP@discussions .microsoft.com> wrote in message news:C0******** *************** ***********@mic rosoft.com... Is it possible to iterate through all the controls collection and make the textboxes alone as read only.I don't see a readonly property for the Control.Can some one help me in this context? I want to do something like this below.But I get a message Readonly is not valid property. foreach (Control ctl in pnlBenefits.Con trols) { if (ctl is TextBox) ctl.ReadOnly=fa lse; }
Yeap unless you have another control with the name TextBox it should map to
System.Web.UI.W ebControls.Text Box
Get into Debug mode. put in a break point and see if its getting executed.
also try setting Enabled property to false.
--
Regards,
Hermit Dave
( http://hdave.blogspot.com)
"GP" <GP@discussions .microsoft.com> wrote in message
news:BD******** *************** ***********@mic rosoft.com... Hi Hermit Dave,
Thanks for you response. This time it didn't error me out, but none of my text boxes is set to readonly. My text boxes are declared using System.Web.UI.W ebControls.Text Box,Is it considered of Type TextBox too while using the Controls iteration.
Thanks GP
"Hermit Dave" wrote:
why dont you do a explicit typecast and then get its readonly property foreach (Control ctl in pnlBenefits.Con trols) { if (ctl is TextBox) { ((TextBox)ctl). ReadOnly = false; } }
i think this should do the job --
Regards,
Hermit Dave (http://hdave.blogspot.com) "GP" <GP@discussions .microsoft.com> wrote in message news:C0******** *************** ***********@mic rosoft.com... Is it possible to iterate through all the controls collection and make
the textboxes alone as read only.I don't see a readonly property for the Control.Can some one help me in this context? I want to do something like this below.But I get a message Readonly is
not valid property. foreach (Control ctl in pnlBenefits.Con trols) { if (ctl is TextBox) ctl.ReadOnly=fa lse; }
Thanks for your responses.
When I set to readonly it didn't work.Still I am able to edit the controls.
But when I set the control enabled=false.I see the text boxes disabled.
But I want the text box to be read only,so that I can get the values in the
viewstate.
foreach (Control ctl in pnlBenefits.Con trols)
{
s= ctl.GetType().N ame;
if (s == "TextBox")
{
((TextBox)ctl). ReadOnly = false;
}
}
}
Even I tried TextBox txt = (TextBox) ctl;
txt.ReadOnly=fa lse;
Thanks
GP
"Hermit Dave" wrote: Yeap unless you have another control with the name TextBox it should map to System.Web.UI.W ebControls.Text Box
Get into Debug mode. put in a break point and see if its getting executed. also try setting Enabled property to false.
--
Regards,
Hermit Dave (http://hdave.blogspot.com) "GP" <GP@discussions .microsoft.com> wrote in message news:BD******** *************** ***********@mic rosoft.com... Hi Hermit Dave,
Thanks for you response. This time it didn't error me out, but none of my text boxes is set to readonly. My text boxes are declared using System.Web.UI.W ebControls.Text Box,Is it considered of Type TextBox too while using the Controls iteration.
Thanks GP
"Hermit Dave" wrote:
why dont you do a explicit typecast and then get its readonly property foreach (Control ctl in pnlBenefits.Con trols) { if (ctl is TextBox) { ((TextBox)ctl). ReadOnly = false; } }
i think this should do the job --
Regards,
Hermit Dave (http://hdave.blogspot.com) "GP" <GP@discussions .microsoft.com> wrote in message news:C0******** *************** ***********@mic rosoft.com... > Is it possible to iterate through all the controls collection and make the > textboxes alone as read only.I don't see a readonly property for the > Control.Can some one help me in this context? > I want to do something like this below.But I get a message Readonly is not > valid property. > foreach (Control ctl in pnlBenefits.Con trols) > { > if (ctl is TextBox) > ctl.ReadOnly=fa lse; > } > > >
i think it could be based on rendering of the textbox. at the end of the day
its the browser that acts on the html attribute in the element and makes it
readonly.
with enabled = false i think you cannot do anything with the instance. ie no
modifications cant even get the focus. you still have access to the object
and the viewstate etc from serverside. The enabled = false is only for
client side rendering.
--
Regards,
Hermit Dave
( http://hdave.blogspot.com)
"GP" <GP@discussions .microsoft.com> wrote in message
news:7D******** *************** ***********@mic rosoft.com... Thanks for your responses. When I set to readonly it didn't work.Still I am able to edit the
controls. But when I set the control enabled=false.I see the text boxes disabled. But I want the text box to be read only,so that I can get the values in
the viewstate. foreach (Control ctl in pnlBenefits.Con trols) { s= ctl.GetType().N ame; if (s == "TextBox") { ((TextBox)ctl). ReadOnly = false; } } } Even I tried TextBox txt = (TextBox) ctl; txt.ReadOnly=fa lse;
Thanks GP
"Hermit Dave" wrote:
Yeap unless you have another control with the name TextBox it should map
to System.Web.UI.W ebControls.Text Box
Get into Debug mode. put in a break point and see if its getting
executed. also try setting Enabled property to false.
--
Regards,
Hermit Dave (http://hdave.blogspot.com) "GP" <GP@discussions .microsoft.com> wrote in message news:BD******** *************** ***********@mic rosoft.com... Hi Hermit Dave,
Thanks for you response. This time it didn't error me out, but none of my text boxes is set to readonly. My text boxes are declared using System.Web.UI.W ebControls.Text Box,Is
it considered of Type TextBox too while using the Controls iteration.
Thanks GP
"Hermit Dave" wrote:
> why dont you do a explicit typecast and then get its readonly
property > foreach (Control ctl in pnlBenefits.Con trols) > { > if (ctl is TextBox) > { > ((TextBox)ctl). ReadOnly = false; > } > } > > i think this should do the job > -- > > Regards, > > Hermit Dave > (http://hdave.blogspot.com) > "GP" <GP@discussions .microsoft.com> wrote in message > news:C0******** *************** ***********@mic rosoft.com... > > Is it possible to iterate through all the controls collection and
make the > > textboxes alone as read only.I don't see a readonly property for
the > > Control.Can some one help me in this context? > > I want to do something like this below.But I get a message
Readonly is not > > valid property. > > foreach (Control ctl in pnlBenefits.Con trols) > > { > > if (ctl is TextBox) > > ctl.ReadOnly=fa lse; > > } > > > > > > > > >
Thanks for you answer
"Hermit Dave" wrote: i think it could be based on rendering of the textbox. at the end of the day its the browser that acts on the html attribute in the element and makes it readonly. with enabled = false i think you cannot do anything with the instance. ie no modifications cant even get the focus. you still have access to the object and the viewstate etc from serverside. The enabled = false is only for client side rendering.
--
Regards,
Hermit Dave (http://hdave.blogspot.com) "GP" <GP@discussions .microsoft.com> wrote in message news:7D******** *************** ***********@mic rosoft.com... Thanks for your responses. When I set to readonly it didn't work.Still I am able to edit the controls. But when I set the control enabled=false.I see the text boxes disabled. But I want the text box to be read only,so that I can get the values in the viewstate. foreach (Control ctl in pnlBenefits.Con trols) { s= ctl.GetType().N ame; if (s == "TextBox") { ((TextBox)ctl). ReadOnly = false; } } } Even I tried TextBox txt = (TextBox) ctl; txt.ReadOnly=fa lse;
Thanks GP
"Hermit Dave" wrote:
Yeap unless you have another control with the name TextBox it should map to System.Web.UI.W ebControls.Text Box
Get into Debug mode. put in a break point and see if its getting executed. also try setting Enabled property to false.
--
Regards,
Hermit Dave (http://hdave.blogspot.com) "GP" <GP@discussions .microsoft.com> wrote in message news:BD******** *************** ***********@mic rosoft.com... > Hi Hermit Dave, > > Thanks for you response. > This time it didn't error me out, but none of my text boxes is set to > readonly. > My text boxes are declared using System.Web.UI.W ebControls.Text Box,Is it > considered of Type TextBox too while using the Controls iteration. > > Thanks > GP > > > "Hermit Dave" wrote: > > > why dont you do a explicit typecast and then get its readonly property > > foreach (Control ctl in pnlBenefits.Con trols) > > { > > if (ctl is TextBox) > > { > > ((TextBox)ctl). ReadOnly = false; > > } > > } > > > > i think this should do the job > > -- > > > > Regards, > > > > Hermit Dave > > (http://hdave.blogspot.com) > > "GP" <GP@discussions .microsoft.com> wrote in message > > news:C0******** *************** ***********@mic rosoft.com... > > > Is it possible to iterate through all the controls collection and make the > > > textboxes alone as read only.I don't see a readonly property for the > > > Control.Can some one help me in this context? > > > I want to do something like this below.But I get a message Readonly is not > > > valid property. > > > foreach (Control ctl in pnlBenefits.Con trols) > > > { > > > if (ctl is TextBox) > > > ctl.ReadOnly=fa lse; > > > } > > > > > > > > > > > > > > >
Hello John,
This may work too...
foreach (TextBox tb in pnlBenefits.Con trols)
{
tb.ReadOnly = false;
}
--
Matt Berther http://www.mattberther.com "GP" <GP@discussions .microsoft.com> wrote in message news:C0******** *************** ***********@mic rosoft.com...
Is it possible to iterate through all the controls collection and make the textboxes alone as read only.I don't see a readonly property for the Control.Can some one help me in this context? I want to do something like this below.But I get a message Readonly is not valid property. foreach (Control ctl in pnlBenefits.Con trols) { if (ctl is TextBox) { TextBox txt = (TextBox) ctl; txt.ReadOnly=fa lse; } } ----- John Saunders This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: paul meaney |
last post by:
All,
myself and another developer have been staring blankly at a screen for
the past 48 hours and are wondering just what stunningly obvious thing
we are missing.
We are trying to load up 2 or more user controls dynamically by adding
to a placeholder defined in page_load. I've included the sample code
for how we are accessing one. The user controls are not rocket science
- just a few text boxes with public accessor properties. We've...
|
by: sean |
last post by:
Hi There,
I am trying to display some textboxes on my page, When I run the code the
textbox is written to the page (when I view source) but not to the screen.
Could someone tell me if I have the syntax correct?
Sean - thanks in advance for your answer
!-- code
|
by: Brian |
last post by:
NOTE ALSO POSTED IN
microsoft.public.dotnet.framework.aspnet.buildingcontrols
I have solved most of my Server Control Collection property issues.
I wrote an HTML page that describes all of the problems that I have
encountered to date and the solutions (if any) that I found.
http://users.adelphia.net/~brianpclab/ServerControlCollectionIssues.htm
This page also has all of the source code in a compressed file that you are
free to download...
|
by: ANDRES BECERRA |
last post by:
Herfried K. Wagner was kind enough to point me to the PropertyGrid control
http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemwindowsformspropertygridclasstopic.asp
I have found a few samples of how to use the PropertyGrid control and have gained a decent understanding of it. But of course, as it usually the case, my needs go far beyond the simple examples shown in online samples. All the online samples show how to take a class...
|
by: charliewest |
last post by:
Hello -
I'm using a Repeater control to render information in a very customized
grid-like table. The Repeater control is binded to a DataSet with several
records of information. Within the Repeater control, I've placed
DropDownLists and CheckBoxes.
When the user has updated the information, he/he clicks the submit button
which is outside the scope of the Repeater control.
| |
by: Mike |
last post by:
Hi,
I am strugling with a simple problem which I can't seem to resolve.
I have an asp.net page which contains a server-control (flytreeview,
which is a kind
of a tree to be exact).
The tree is being updated by some other process through remoting.
When the page loads, I init the tree, and in my browser I can see the
initialized tree.
The problem is that every time that I receive update to tree from the
remote process,
|
by: |
last post by:
Hello,
Does anyone have an idea on how I can filter the data in the gridview
control that was returned by an sql query?
I have a gridview that works fine when I populate it with data. Now I want
to look at that data and filter it based on what is in it.
I know that this could have been done with data sets and data views in
asp.net 1.1 but how is this done now in asp.net 2.0?
|
by: Mike |
last post by:
Hi. I can't figure out why a button's click event is not firing in a
templated control I've created (first time I've tried creating one).
Please can someone help? On a point of lesser importance, how can I get
the designer to realise that my control can contain markup?
This is all ASP.Net v 2.0
This is my default.aspx:
Below is the source of three files: Default.aspx, Default.aspx.cs and
|
by: Christian |
last post by:
Hi all,
i already posted this in dotnet.vb.controls but i need some help, so i
cant wait...
I have written a web control library and have some problems with it.
The Library contains only two Controls: a menu bar and a menu item
class which can have sub items (from the same class and type).
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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 most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |