473,585 Members | 2,555 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

enable a control programatically vb.net (asp)

10 New Member
Hope someone could help.

I read all the controls on a page using the following statement:

For i = 0 To Page.Form.Contr ols.Count - 1
try
Page.Form.Contr ols.Item(i).Vis ible = False
' here I would not like to set the property to "visible" to false.
'I would rather set the enable property to false
Catch
End Try
Next

The controls are checked against a security table whether the user should have access to it or not. If not access, the enable property must be set to false.
On entering the dot - no "enable" property is shown and I dont know how to get to work. I use visio studio 2005

Please help!
Regards
Francois
Oct 26 '06 #1
1 2711
pmatty9779
1 New Member
Hai

i'm a rookie in programming. when i came accross a similar problem i searched the net then i got this posting

i tried my self and got a solution
this function below solvet the problem


Private Function EnableCntrls(By Val Switch As Boolean) As Boolean
Dim i As Integer
If Switch = False Then
For i = 0 To frmDefault.Cont rols.Count - 1
Dim Str As String
Str = frmDefault.Cont rols.Item(i).Ge tType().ToStrin g
If Str = "System.Web.UI. WebControls.Tex tBox" Then
Dim cntrl As WebControl
cntrl = frmDefault.Find Control(frmDefa ult.Controls.It em(i).ID)
cntrl.Enabled = False
End If
If Str = "System.Web.UI. WebControls.Dro pDownList" Then
Dim cntrl As WebControl
cntrl = frmDefault.Find Control(frmDefa ult.Controls.It em(i).ID)
cntrl.Enabled = False
End If
Next
Else
For i = 0 To frmDefault.Cont rols.Count - 1
Dim Str As String
Str = frmDefault.Cont rols.Item(i).Ge tType().ToStrin g
If Str = "System.Web.UI. WebControls.Tex tBox" Then
Dim cntrl As WebControl
cntrl = frmDefault.Find Control(frmDefa ult.Controls.It em(i).ID)
cntrl.Enabled = True
End If
If Str = "System.Web.UI. WebControls.Dro pDownList" Then
Dim cntrl As WebControl
cntrl = frmDefault.Find Control(frmDefa ult.Controls.It em(i).ID)
cntrl.Enabled = True
End If
Next
End If
End Function
Jan 6 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
7735
by: Stu Carter | last post by:
Hi, I have an aspx page where some controls are initially disabled by the code-behind 'Page_Load' event. I want these controls to be dynamically enabled when the user checks a checkbox. Because I don't want a post-back, I added some javascript to do this However, using client-side JS, I cannot enable any controls that have been...
6
11274
by: martin | last post by:
Hi, I am a web page and a web user control. My web user control is placed in my web page using the following directive <%@ Register TagPrefix="uc1" TagName="Header" Src="WebControls/Header.ascx" %> The web user control contains the following server controls
1
1277
by: francois | last post by:
Hi, I would like to add a USER control (not custom control) programmatically to my aspx page. I am using something like the following in my page_load code : * Bos.UserControls.HeaderFinance header = new HeaderFinance(); this.Controls.Add(header); *
2
1869
by: francois | last post by:
Hi, I would like to add a USER control (not custom control) programmatically to my aspx page. I am using something like the following in my page_load code : * Bos.UserControls.HeaderFinance header = new HeaderFinance(); this.Controls.Add(header); *
2
1191
by: Edgardo Rossetto | last post by:
Is it possible? Or I must add the control programatically in order to make changes programatically? Edgardo
2
3219
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 he had placed will be displayed in a DataList. Also assume that the OrderID of the last order is 13. The details of the earlier orders placed by...
1
1828
by: OceanBreeze | last post by:
I am new to .Net. I am using ASP 2.0 and C#. I want to pupolate a data grid programatically using the values obtained from a list conating domain objects. E.g., DAL.GetEmployee() returns a List of all Employee object. Each Employee object has two attributes (ID and Name). I drop a data grid control on ASP.Net Web form. Data grid will...
1
2093
by: danyeungw | last post by:
I get the following from the link http://support.microsoft.com/kb/314206. I need to have both work - the page stays where it is and set focus to next control. Does anyone have solution? I have been working on this for days. I am using ASP.NET 2003. Thanks. DanYeung PRB: Controls Lose Focus When You Enable SmartNavigation and...
1
4585
by: =?Utf-8?B?Tmlrb2xheSBQb2Rrb2x6aW4=?= | last post by:
Goon afternoon, Community! I'm sorry for a post in wrong place, but couldn't find more appropriate place for that. Could you be so kind and help me with dynamic creating controls in asp.net. I need to set a positions of control programaticall.
0
7904
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7835
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7947
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...
0
8209
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 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...
1
5707
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3831
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...
1
2340
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 we have to send another system
1
1444
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1171
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.