473,545 Members | 1,878 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 2707
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
7731
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
11271
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
1273
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
1865
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
1189
by: Edgardo Rossetto | last post by:
Is it possible? Or I must add the control programatically in order to make changes programatically? Edgardo
2
3214
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
1827
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
2089
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
4584
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
7486
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
7676
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, 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. ...
0
7776
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...
0
6001
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5347
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
3473
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...
0
3456
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1032
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
729
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.