Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > form objects into class objects

Reply
Thread Tools

form objects into class objects

 
 
=?Utf-8?B?c3RldmVuIHNjYWlmZQ==?=
Guest
Posts: n/a
 
      07-05-2006
Hi I have created a class that inherits from dictionarybase code below.

Public Class FrmLabels
Inherits Label
Private m_Lbl As Label

Public Property lbl() As Label
Get
Return m_Lbl
End Get
Set(ByVal Value As Label)
m_Lbl = Value
End Set
End Property

Sub New(ByVal lbl As Label)
Me.m_Lbl = m_Lbl
End Sub

End Class

Public Class FrmDDL
Inherits DropDownList
Private m_DDL As DropDownList

Public Property DDL() As DropDownList
Get
Return m_DDL
End Get
Set(ByVal Value As DropDownList)
m_DDL = Value
End Set
End Property

Sub New(ByVal DDL As DropDownList)
Me.m_DDL = m_DDL
End Sub

End Class

Public Class FrmTxt
Inherits HtmlInputText
Private m_DDL As HtmlInputText

Public Property DDL() As HtmlInputText
Get
Return m_DDL
End Get
Set(ByVal Value As HtmlInputText)
m_DDL = Value
End Set
End Property

Sub New(ByVal DDL As HtmlInputText)
Me.m_DDL = m_DDL
End Sub

End Class

Public Class FormDictionary
Inherits DictionaryBase

Sub add(ByVal key As String, ByVal D As Object)
Me.Dictionary.Add(key, D)
End Sub

Sub remove(ByVal key As String)
Me.Dictionary.Remove(key)
End Sub

Default Property item(ByVal key As String) As Object
Get
Return Me.Dictionary.Item(key)
End Get
Set(ByVal Value As Object)
Me.Dictionary.Item(key) = Value
End Set
End Property

Function contains(ByVal key As String) As Boolean
Return Me.Dictionary.Contains(key)
End Function
End Class

Basically the 3 types of objects i want to pass from my page into a function
defined in another class are label, htmlinputtext and dropdownlist.

and i have this code in my form

For Each ctrl In pnlForm.Controls
If TypeOf ctrl Is HtmlInputText Then
frmDict.add(ctrl.ID, New FrmTxt(CType(ctrl,
HtmlInputText)))
End If
If TypeOf ctrl Is Label And ctrl.ID <> "" Then
frmDict.add(ctrl.ID, New FrmLabels(CType(ctrl,
Label)))
End If
If TypeOf ctrl Is DropDownList Then
frmDict.add(ctrl.ID, New FrmDDL(CType(ctrl,
DropDownList)))
End If
If TypeOf ctrl Is suppliersList Then
frmDict.add(ctrl.ID, ctrl)
End If
Next

This adds each of the objects into the dictionary however i cant get the ID.
I am using the syntax ctype(frmdict.item("lblReqBy"), label).ID but it
returns nothing.

I have a web user control on their (SuppliersList) which contains a
dropdownlist, i haven't created a class for this as its only on the page
once, if i use the following syntax

ctype(frmdict.item("Suppliers1"), suppliersList).Controls.Item(0).ID

It gives me the ID of the dropdownlist. Can anyone help me out as to why I
can't access the ID property of the controls. Basically I will populate the
text property, selectedvalue property in a function i am writing and modify
the page appropriately, the reason i am doing this is because the same
routine is used on two of my pages and i only want to write it once and stick
it in a class.

TIA
 
Reply With Quote
 
 
 
 
=?Utf-8?B?c3RldmVuIHNjYWlmZQ==?=
Guest
Posts: n/a
 
      07-06-2006
Hi i have played around with it this morning and noticed that each of the sub
new in the class was wrong so i changed it to read me.m_lbl = lbl. However i
still had the same issues described

Sub New(ByVal lbl As Label)
Me.m_Lbl = m_Lbl
End Sub

i also changed my for next loop to read

For Each ctrl In pnlForm.Controls
If TypeOf ctrl Is HtmlInputText Then
frmDict.add(ctrl.ID, ctrl)
End If
If TypeOf ctrl Is Label And ctrl.ID <> "" Then
frmDict.add(ctrl.ID, ctrl)
End If
If TypeOf ctrl Is DropDownList Then
frmDict.add(ctrl.ID, ctrl)
End If
If TypeOf ctrl Is suppliersList Then
frmDict.add(ctrl.ID, ctrl)
End If
Next

This appears to be working ok, run a few tests in the immediate window. In
my vb.net book it says to create classes like i have done and add them to a
dictionary or collection object. I think the idea is to create early bound
objects i remember something about how it would operate faster, although
there must be something wrong in what i have written so far.

TIA

"steven scaife" wrote:

> Hi I have created a class that inherits from dictionarybase code below.
>
> Public Class FrmLabels
> Inherits Label
> Private m_Lbl As Label
>
> Public Property lbl() As Label
> Get
> Return m_Lbl
> End Get
> Set(ByVal Value As Label)
> m_Lbl = Value
> End Set
> End Property
>
> Sub New(ByVal lbl As Label)
> Me.m_Lbl = m_Lbl
> End Sub
>
> End Class
>
> Public Class FrmDDL
> Inherits DropDownList
> Private m_DDL As DropDownList
>
> Public Property DDL() As DropDownList
> Get
> Return m_DDL
> End Get
> Set(ByVal Value As DropDownList)
> m_DDL = Value
> End Set
> End Property
>
> Sub New(ByVal DDL As DropDownList)
> Me.m_DDL = m_DDL
> End Sub
>
> End Class
>
> Public Class FrmTxt
> Inherits HtmlInputText
> Private m_DDL As HtmlInputText
>
> Public Property DDL() As HtmlInputText
> Get
> Return m_DDL
> End Get
> Set(ByVal Value As HtmlInputText)
> m_DDL = Value
> End Set
> End Property
>
> Sub New(ByVal DDL As HtmlInputText)
> Me.m_DDL = m_DDL
> End Sub
>
> End Class
>
> Public Class FormDictionary
> Inherits DictionaryBase
>
> Sub add(ByVal key As String, ByVal D As Object)
> Me.Dictionary.Add(key, D)
> End Sub
>
> Sub remove(ByVal key As String)
> Me.Dictionary.Remove(key)
> End Sub
>
> Default Property item(ByVal key As String) As Object
> Get
> Return Me.Dictionary.Item(key)
> End Get
> Set(ByVal Value As Object)
> Me.Dictionary.Item(key) = Value
> End Set
> End Property
>
> Function contains(ByVal key As String) As Boolean
> Return Me.Dictionary.Contains(key)
> End Function
> End Class
>
> Basically the 3 types of objects i want to pass from my page into a function
> defined in another class are label, htmlinputtext and dropdownlist.
>
> and i have this code in my form
>
> For Each ctrl In pnlForm.Controls
> If TypeOf ctrl Is HtmlInputText Then
> frmDict.add(ctrl.ID, New FrmTxt(CType(ctrl,
> HtmlInputText)))
> End If
> If TypeOf ctrl Is Label And ctrl.ID <> "" Then
> frmDict.add(ctrl.ID, New FrmLabels(CType(ctrl,
> Label)))
> End If
> If TypeOf ctrl Is DropDownList Then
> frmDict.add(ctrl.ID, New FrmDDL(CType(ctrl,
> DropDownList)))
> End If
> If TypeOf ctrl Is suppliersList Then
> frmDict.add(ctrl.ID, ctrl)
> End If
> Next
>
> This adds each of the objects into the dictionary however i cant get the ID.
> I am using the syntax ctype(frmdict.item("lblReqBy"), label).ID but it
> returns nothing.
>
> I have a web user control on their (SuppliersList) which contains a
> dropdownlist, i haven't created a class for this as its only on the page
> once, if i use the following syntax
>
> ctype(frmdict.item("Suppliers1"), suppliersList).Controls.Item(0).ID
>
> It gives me the ID of the dropdownlist. Can anyone help me out as to why I
> can't access the ID property of the controls. Basically I will populate the
> text property, selectedvalue property in a function i am writing and modify
> the page appropriately, the reason i am doing this is because the same
> routine is used on two of my pages and i only want to write it once and stick
> it in a class.
>
> TIA

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
class objects, method objects, function objects 7stud Python 11 03-20-2007 06:05 PM
struts indexed form elements not getting into form bean apaeth@fortdearborn.com Java 1 01-07-2006 09:29 PM
Class A contains class B, class B points to class A Joseph Turian C++ 5 12-30-2005 03:24 PM
Nested Class, Member Class, Inner Class, Local Class, Anonymous Class E11 Java 1 10-12-2005 03:34 PM
A parameterized class (i.e. template class / class template) is not a class? christopher diggins C++ 16 05-04-2005 12:26 AM



Advertisments