I was doing this in a .Net 1.1 site, but it doesn't work in 2.0, because the
objects aren't public (I think)
For k = 1 To iDDLCount
ddlObject = CallByName(oPar ent, sDDLName & k, CallType.Get)
ddlObject.Items .Clear()
Next
Any ideas?
Thanks, Dave 5 3858
I'm not entirely sure what you're trying to do, but perhaps you can loop
through all the controls in a form using control tree recursion as I've
shown in this code sample: http://SteveOrr.net/faq/ControlTreeRecursion.aspx
--
I hope this helps,
Steve C. Orr, MCSD, MVP http://SteveOrr.net
"Dave H" <Da***@noemail. nospam> wrote in message
news:-L************** *************** *@comcast.com.. . I was doing this in a .Net 1.1 site, but it doesn't work in 2.0, because the objects aren't public (I think)
For k = 1 To iDDLCount ddlObject = CallByName(oPar ent, sDDLName & k, CallType.Get) ddlObject.Items .Clear() Next
Any ideas?
Thanks, Dave
I have a class that I put support code in, it's why I have to passs the
parent.
Say, on a page, I have 5 controls called 'DropDownList1' ...'DropDownLis t5'
I use this code to set them, and fill them with thier defaults. I'll give
this a try..
"Steve C. Orr [MVP, MCSD]" <St***@Orr.ne t> wrote in message
news:Ox******** ******@TK2MSFTN GP02.phx.gbl... I'm not entirely sure what you're trying to do, but perhaps you can loop through all the controls in a form using control tree recursion as I've shown in this code sample: http://SteveOrr.net/faq/ControlTreeRecursion.aspx
-- I hope this helps, Steve C. Orr, MCSD, MVP http://SteveOrr.net
"Dave H" <Da***@noemail. nospam> wrote in message news:-L************** *************** *@comcast.com.. . I was doing this in a .Net 1.1 site, but it doesn't work in 2.0, because the objects aren't public (I think)
For k = 1 To iDDLCount ddlObject = CallByName(oPar ent, sDDLName & k, CallType.Get) ddlObject.Items .Clear() Next
Any ideas?
Thanks, Dave
Thanks Steve for you informative input.
Hi Dave,
Based on my understanding, you question is how to use a generic method to
iterate child controls on a form and clear all DropDownList's items. If
I've misunderstood anything, please feel free to post here.
Protected Sub Button1_Click(B yVal sender As Object, ByVal e As
System.EventArg s) Handles Button1.Click
ClearAllDropDow nList(Me)
End Sub
Public Sub ClearAllDropDow nList(ByVal parent As Control)
For Each ctl As Control In parent.Controls
If TypeOf ctl Is DropDownList Then
CType(ctl, DropDownList).I tems.Clear()
Else
For Each subctl As Control In ctl.Controls
ClearAllDropDow nList(subctl)
Next
End If
Next
End Sub
Hope this helps. Please feel free to post here if anything is unclear.
Regards,
Walter Wang (wa****@online. microsoft.com, remove 'online.')
Microsoft Online Community Support
=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.
Thanks Walter.
My problem turned out to be the hierarchy of the control.
Using a MasterPage the parent was really the ContentControl. .. so I just
changed the code to:
oParent = CType(oParent.F indControl("Con tentPlaceHolder 1"),
ContentPlaceHol der)
Then it worked normally..
Maybe not the best way, but it got me past the problem..
"Walter Wang [MSFT]" <wa****@online. microsoft.com> wrote in message
news:uz******** ******@TK2MSFTN GXA01.phx.gbl.. . Thanks Steve for you informative input.
Hi Dave,
Based on my understanding, you question is how to use a generic method to iterate child controls on a form and clear all DropDownList's items. If I've misunderstood anything, please feel free to post here.
Protected Sub Button1_Click(B yVal sender As Object, ByVal e As System.EventArg s) Handles Button1.Click ClearAllDropDow nList(Me) End Sub
Public Sub ClearAllDropDow nList(ByVal parent As Control) For Each ctl As Control In parent.Controls If TypeOf ctl Is DropDownList Then CType(ctl, DropDownList).I tems.Clear() Else For Each subctl As Control In ctl.Controls ClearAllDropDow nList(subctl) Next End If Next End Sub
Hope this helps. Please feel free to post here if anything is unclear.
Regards, Walter Wang (wa****@online. microsoft.com, remove 'online.') Microsoft Online Community Support
=============== =============== =============== ===== When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from your issue. =============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.
Hi Dave,
Thank you for your update.
Besides using your way to find the ContentPlaceHol der control and get the
child controls, I think using the recursive way to find the DropDownList
should work too since when compiled, the master page and the content page
will get merged.
You can verify this by turning on trace output of the content page:
<%@ Page Language="VB" MasterPageFile= "~/MasterPage.mast er"
AutoEventWireup ="false" CodeFile="Defau lt2.aspx.vb" Inherits="Defau lt2"
title="Untitled Page" Trace="true" %>
And view the page, you will see the control hierarchy such as:
__Page ASP.default2_as px 1411 0 0
ctl00 ASP.masterpage_ master 1411 0 0
ctl00$ctl02 System.Web.UI.L iteralControl 175 0 0
ctl00$ctl00 System.Web.UI.H tmlControls.Htm lHead 46 0 0
ctl00$ctl01 System.Web.UI.H tmlControls.Htm lTitle 33 0 0
ctl00$ctl03 System.Web.UI.L iteralControl 14 0 0
aspnetForm System.Web.UI.H tmlControls.Htm lForm 1156 0 0
ctl00$ctl04 System.Web.UI.L iteralControl 21 0 0
ctl00$ContentPl aceHolder1
System.Web.UI.W ebControls.Cont entPlaceHolder 746 0 0
ctl00$ContentPl aceHolder1$ctl0 0
System.Web.UI.L iteralControl 21 0 0
ctl00$ContentPl aceHolder1$Drop DownList1
System.Web.UI.W ebControls.Drop DownList
So passing "Me" to the function I've written will correctly walk down all
the child controls.
Hope this helps. Please feel free to post here if anything is unclear.
Regards,
Walter Wang (wa****@online. microsoft.com, remove 'online.')
Microsoft Online Community Support
=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Adam Parkin |
last post by:
Hi all, what I want to do is write a function to toggle the enabled field of
all controls within a frame, but what I can't figure out is how does one
iterate through all controls in a frame object?
For example, if I wanted to iterate through all controls in a form, I'd
write something like:
Dim x
For Each x In frmMyForm.Controls
x.Enabled = Not x.Enabled
|
by: Jeremy |
last post by:
I have been trying to iterate through the controls on my form and preset all
textboxes to a cssClass. Unfortunately, I have been unable to figure out
how to recursively move through sub-controls and all of my textboxes are in
asp panels. The code I have can see the panels but not what is in them.
Help please.
Current code:
|
by: Sandra Castellanos |
last post by:
I want to know if there is a way to easily iterate trough all the controls
contained, say, in a table, including the controls that can be inside the
cells and in any nested tables that are inside?
Regards,
Sandra
|
by: Dany P. Wu |
last post by:
Hi everyone,
I created a page which contains a two-column table. The first column has a
bunch of labels, and the second a bunch of textboxes. Here's the code:
======================================================
Protected WithEvents Container As System.Web.UI.WebControls.PlaceHolder
Private Sub ConstructEditTable()
Container.Controls.Add(New LiteralControl("<table>" & vbNewLine))
|
by: Milsnips |
last post by:
hi there,
i have a strange problem. I want to programatically loop through each
control on a page, but am having issues.
my test example:
1. header.ascx - the ascx control finds all the child controls no problems
2. default.aspx - i dont find any controls that are placed directly on the
| |
by: John Buchmann |
last post by:
I thought this would not be difficult, but i'm stumped!
I need to iterate through a bunch of form fields, and
read the data (value, text, etc.) from them.
(I need to iterate through them programmatically because
it is not known ahead of time which form fields will be
displayed on the browser. The fields will be displayed
or hidden depending on what the user just clicked.)
|
by: Ali |
last post by:
I used to clear my page's control in Visual Studio 2003 using code like this:
Dim c As Control
For Each c In Page.Controls(1).Controls
If TypeOf c Is TextBox Then
CType(c, TextBox).Text = Nothing
End If
If TypeOf c Is DropDownList Then
CType(c, DropDownList).SelectedIndex = 0
End If
Next
|
by: Bill44077 |
last post by:
Hi,
I am trying to iterate though the controls on a content page that has a
master page so I can disable text. If it weren't on a content page it is
simple:
foreach (Control c in Page.Controls)
{
if (c is TextBox)
{
|
by: David Veeneman |
last post by:
Is there a way to iterate the components on a form?
I need to determine whether an instance of my custom component (a
System.ComponentModel component) is present in a form. I have tried
iterating the Controls collection, but components do not appear to be in
that collection-- I think it's because components inherit from
MarshalByRefObject, rather than Control.
So, how do I find a form's components collection? Thanks in advance.
|
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 usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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: 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: 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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |