473,503 Members | 12,367 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Change control type at runtime

RSH
Hi,

Is it possible to change the type of controls at run-time?

In other words I have a form with TextBoxes etc. on it. If the user only
has readonly privelages I was wondering if I could change the type of
control from TextBox to a Label or something and set the text
programatcially as I would the textbox.

If so how do I do it?

Thanks!
Ron
Jan 11 '07 #1
3 3221
Ron,

Once an object has been created, you can't change it's type. But you can
style a textbox that it will look like a label.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"RSH" <wa*************@yahoo.comwrote in message
news:Oz*************@TK2MSFTNGP04.phx.gbl...
Hi,

Is it possible to change the type of controls at run-time?

In other words I have a form with TextBoxes etc. on it. If the user only
has readonly privelages I was wondering if I could change the type of
control from TextBox to a Label or something and set the text
programatcially as I would the textbox.

If so how do I do it?

Thanks!
Ron

Jan 11 '07 #2
Check out this code sample at ASPNet101.com:
http://aspnet101.com/aspnet101/aspne...?code=readonly
It specifically shows how to do what you're talking about.
--
David Wier
MVP/ASPInsider
http://aspnet101.com
http://aspexpress.com

"Eliyahu Goldin" <RE**************************@mMvVpPsS.orgwrote in
message news:O9**************@TK2MSFTNGP06.phx.gbl...
Ron,

Once an object has been created, you can't change it's type. But you can
style a textbox that it will look like a label.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"RSH" <wa*************@yahoo.comwrote in message
news:Oz*************@TK2MSFTNGP04.phx.gbl...
Hi,

Is it possible to change the type of controls at run-time?

In other words I have a form with TextBoxes etc. on it. If the user
only
has readonly privelages I was wondering if I could change the type of
control from TextBox to a Label or something and set the text
programatcially as I would the textbox.

If so how do I do it?

Thanks!
Ron


Jan 11 '07 #3
RSH
Good stuff...sometimes the solution is easier than you think.

I created a CSS class for readonly and editable and based on the credentials
I switched the class out on the fly. Seems to work pretty slick in my test.

Thanks for the ideas!

Ron
"RSH" <wa*************@yahoo.comwrote in message
news:Oz*************@TK2MSFTNGP04.phx.gbl...
Hi,

Is it possible to change the type of controls at run-time?

In other words I have a form with TextBoxes etc. on it. If the user only
has readonly privelages I was wondering if I could change the type of
control from TextBox to a Label or something and set the text
programatcially as I would the textbox.

If so how do I do it?

Thanks!
Ron

Jan 11 '07 #4

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

Similar topics

3
8791
by: Roberto Castro | last post by:
Hello! I have been assigned for the first time an adp Access project and so far I have managed to make the changes needed for some requirements. However, I am struggling to find the place where...
13
6056
by: Andrew | last post by:
I use conditional compiler constants, set through the VBA IDE in Tools, <projectname> Properties, that I refer to throughout my code to control which code is used during development, and which...
3
11305
by: | last post by:
Hi,all I want to change Control's size&location in runtime ,(C#) but i dont know how to do! :(so, can you provide me with document about this. my email: zhonghua@rinpak.com.cn ...
0
964
by: hugo batista | last post by:
Hi Sorry to crosspost, but i'm not knowing what should be the correct newsgroup for this.... I have a web application which i want to show a windows forms user control in my web form. (lets...
3
1919
by: Sky Sigal | last post by:
I coming unglued... really need some help. 3 days chasing my tail all over MSDN's documentation ...and I'm getting nowhere. I have a problem with TypeConverters and storage of expandableobjects...
1
4756
by: Leo | last post by:
I created a user control which is some text contained in a HtmlTable. I put this control into main form. I would like to have the ability to move this control around in the main form. I think one...
20
5594
by: Guadala Harry | last post by:
In an ASCX, I have a Literal control into which I inject a at runtime. litInjectedContent.Text = dataClass.GetHTMLSnippetFromDB(someID); This works great as long as the contains just...
3
10985
by: RG | last post by:
For a Windows project in VB.NET 2003: I need a Calendar that’s much larger than the MonthCalendar control in the toolbox; it needs to fill the whole screen (at least approximately ). VB...
2
12773
by: planetthoughtful | last post by:
Hi All, I have an ASP.NET page that displays a GridView control based on an ObjectDataSource control. I'm wondering if it's possible to base the ObjectDataSource in question on a parameter...
0
7098
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
7296
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
7364
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
7470
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...
1
5026
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...
0
3186
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...
0
1524
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 ...
1
751
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
405
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...

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.