473,591 Members | 2,842 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

A custom button with a collection?

I am trying to create a custom button control for the web that, when clicked,
disables and changes the text of itself and a bunch of other controls (in the
collection). My goal is to end up with a button that prevents the user from
submitting a form back multiple times and also prevents them from submitting
the form and then clicking something else before the postback can finish
processing.

What I have is a working button that disables and changes the text of
itself. It generates the <input> tag and associated attributes and it
generates the javascript and the postback event and adds it to the tag. My
hope was to add a collection to the control to generate the javascript to
disable other controls and change their text as well. I wanted to be able to
add it to the properties window (similar to adding Items to a dropdownlist)
and use System.Web.UI.D esign.WebContro ls.ListItemsCol lectionEditor to create
the editor. The problem I am having is adding the collection.

In an attempt to make this work I have added 3 additional classes (basing
this all off of a non-function example of how to create a custom
ListItemsCollec tionEditor class I found on the web by Brian Mains). The
"ControlsToDisa ble" Class is the defines the object that the collection will
store. The "ControlsToDisa bleCollection" Class inherits from CollectionBase
and its only property is "Item". It also has a few functions for adding
items/ removing items/ etc. The "ControlsToDisa bleCollectionEd itor" Class
(you like the naming convention?) inherits from the ListItemsCollec tionEditor
class and sets the type of class to my "ControlsToDisa bleCollection" Class.
The "Button" Class then has a property that calls the collection. This works
in visual studio and allows me to use the editor to add items and stores
them... however when I run the page with the control on it and get a count of
items in the collection it's 0 and when I go back to the into visual studio
and open up the collection the list is empty. I was under the impression from
the article that the that the collection would be rendered on the page in the
HTML like items in a drop down are rendered, but they are not. I'm not sure
where they are getting stored while I'm in visual studio.

I am perfectly happy to go in a completely different direction with this if
that's what it takes, but I really want to be able to use the
ListItemsCollec tionEditor class, as there will be a number of people using
this control and the familiarity means I don't have to repeatedly explain how
to use it. Now if you are still with me (I'm sorry) I'll put the classes
below in the order that I mentioned them. Some stuff has been left out to
help reduce the size of this posting. Thanks in advance for any help that you
can provide.

------------ControlsToDisab le----------------------------------------

Imports System.Web.UI
Imports System.Componen tModel

Public Class ControlsToDisab le
Private _Name As String
Public Property Name() As String
Get
Return _Name
End Get
Set(ByVal Value As String)
_Name = Value
End Set
End Property

Public Sub New()
'Do Nothing
End Sub

Public Sub New(ByVal Name As String)
_Name = Name
End Sub

Public Overrides Function tostring() As String
Return _Name
End Function

End Class

------------ControlsToDisab leCollection------------------------------

Imports System.Web.UI
Imports System.Web.UI.W ebControls
Imports System.Componen tModel

<DefaultPropert y("Item")> _
Public Class ControlsToDisab leCollection
Inherits CollectionBase
<DesignerSerial izationVisibili ty(DesignerSeri alizationVisibi lity.Visible), _
PersistenceMode (PersistenceMod e.Attribute)> _
Default Public Property Item(ByVal intIndex As Integer) As
ButtonsToDisabl e
Get
Return DirectCast(list .Item(intIndex) , ControlsToDisab le)
End Get
Set(ByVal Value As ControlsToDisab le)
list.Item(intIn dex) = Value
End Set
End Property

Public Function Add(ByVal objItem As ControlsToDisab le) As Integer
Return list.Add(objIte m)
End Function

Public Function Add(ByVal Name As String) As Integer
Return list.Add(New ControlsToDisab le(Name))
End Function

Public Function Contains(ByVal objItem As ControlsToDisab le) As Boolean
Return list.Contains(o bjItem)
End Function

Public Sub Insert(ByVal intIndex As Integer, ByVal objItem As
ControlsToDisab le)
list.Insert(int Index, objItem)
End Sub

Public Sub Remove(ByVal objItem As ControlsToDisab le)
list.Remove(obj Item)
End Sub

End Class

------------ControlsToDisab leCollectionEdi tor------------------------

Public Class ControlsToDisab leCollectionEdi tor
Inherits System.Web.UI.D esign.WebContro ls.ListItemsCol lectionEditor

Public Sub New()
MyBase.New(GetT ype(ControlsToD isableCollectio n))
End Sub
End Class

------------Button---------------------------------------------------

Imports System.Componen tModel
Imports System.Web.UI
Imports System.Drawing

<ToolboxBitmap( GetType(System. Web.UI.WebContr ols.Button)), _
DefaultEvent("C lick"), DefaultProperty ("Text"), _
ParseChildren(F alse), PersistChildren (True)> _
Public Class Button
Inherits System.Web.UI.W ebControls.WebC ontrol

Private _ControlListToD isable As New controlsToDisab leCollection

<Bindable(True) , Browsable(True) , Category("Data" ), _
Editor(GetType( controlsToDisab leCollection),
GetType(System. Web.UI.Design.W ebControls.List ItemsCollection Editor)), _

DesignerSeriali zationVisibilit y(DesignerSeria lizationVisibil ity.Content), _
PersistenceMode (PersistenceMod e.InnerProperty )> _
Public Property ControlListToDi sable() As ControlsToDisab leCollection
Get
Return _ControlListToD isable
End Get
Set(ByVal Value As ControlsToDisab leCollection)
_ControlListToD isable = Value
End Set
End Property

Public Sub New()
MyBase.New(Html TextWriterTag.I nput)
End Sub

End Class
Jul 22 '05 #1
0 1917

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

Similar topics

2
9704
by: PK | last post by:
Hello, I am looking for help on the following. I'm trying to create a custom browser toolbar button that will do a few things. One that I'm trying to do at the moment is just simply return the URL of whatever page the user is visiting. I wanted to create a Win32 application using VB.NET. If there is a better way of doing this please let me know. I assume there needs to be some sort of client side code. I was originally leaning...
2
2732
by: SammyBar | last post by:
Hi, I'm trying to bind a custom collection class to a data grid, following the guidelines from the article http://msdn.microsoft.com/msdnmag/issues/05/08/CollectionsandDataBinding/default.aspx. The problem is the article is in VisualBasic. I already get the collection to be recognized as a Data Source by the IDE. It populated the DataGrid correctly from the fields on the items object of the collection, but I can't get the DataGrid to...
0
1282
by: Tom | last post by:
I am developing a page that will contain multiple instances of a Composite Custom Control that i have developed. The problem is that the user will determine at run time how many of the control will be added to the page at runtime (through add or delete button clicks). I have created a class for the control(PersonPanel), and have created a collection class(PersonPanelCollection)to hold and store all the controls at runtime, but due to the...
0
230
by: Sundown | last post by:
I am trying to create a custom button control for the web that, when clicked, disables and changes the text of itself and a bunch of other controls (in the collection). My goal is to end up with a button that prevents the user from submitting a form back multiple times and also prevents them from submitting the form and then clicking something else before the postback can finish processing. What I have is a working button that disables...
19
4903
by: Jamey Shuemaker | last post by:
I'm in the process of expanding my knowledge and use of Class Modules. I've perused MSDN and this and other sites, and I'm pretty comfortable with my understanding of Class Modules with the exception of custom Collection Classes. Background: I'm developing an A2K .mdb to be deployed as an .mde at my current job-site. It has several custom controls which utilize custom classes to wrap built-in controls, and add additional functionality....
0
3249
by: Jeremy Chapman | last post by:
I have included below virtually all the code to a control I'm trying to build. My issue is that an array list property in my control does not get persisted properly to the aspx page code in design time. If I type the code in the aspx manually it does get parsed correctly though. This is an example of the aspx code that gets parsed correctly. For some reason, if I changed update the Tab property of the control through the GUI at design...
0
1276
by: cranley | last post by:
Hi. I'm currently building a custom control. On my custom control is a colleciton property which I wish to edit with the VS.NET collection editor. So far I have everything working as planned, however I want to update the designer UI of my custom control when a person modifies the collection property via the Collection Editor in the designer (similar to when you add/remove columns from a DataGridView). I've looked and looked, however,...
11
10103
by: =?Utf-8?B?bWljaGFlbCBzb3JlbnM=?= | last post by:
I have worked with application settings in VS2005 and C# for awhile, but usually with standard types. I have been trying to store a custom container/class/type in an application setting and I have seen erratic results. I am aware of one known defect where user classes do not show up in the list of types on the Property/Settings page in the visual designer and I am wondering if I am encountering some other peculiar issue, or if there are...
1
4376
by: asharda | last post by:
I have a custom property grid. I am using custom property grid as I do not want the error messages that the propertygrid shows when abphabets are entered in interger fields. The custom property grid doesn't show colloections i.e. if I have a List<Objectthen the Collection is shown but when I click on the "..." button next to it nothing comes up. If I say CustomPropertyGrid p = new CustomPropertyGrid(); p.SelectedObject = new...
0
7870
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,...
0
8362
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 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...
1
7992
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,...
0
8225
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
5732
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3850
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...
0
3891
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1465
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1199
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.