Problem with Controls...

  • Thread starter Thread starter Raphaël Désalbres
  • Start date Start date
R

Raphaël Désalbres

Hello, everybody,

I'm having a problem creating a control...All I want to do is a simple poll
system, so I need to input (trough a ListitemCollection) the values from the
user.

The problem is I'm getting an error each time I try to modify the elements,
I don't know why....

If anyone can help, I would appreciate...

Raphaël...







Imports System.ComponentModel

Imports System.Web.UI

Imports System.Web.UI.WebControls

<DefaultProperty("Text"), ToolboxData("<{0}:WebCustomControl1
runat=server></{0}:WebCustomControl1>")> Public Class WebCustomControl1

Inherits System.Web.UI.WebControls.WebControl

Dim _text As String

<Bindable(True), Category("Appearance"), DefaultValue("")> Property [Text]()
As String

Get

Return _text

End Get

Set(ByVal Value As String)

_text = Value

End Set

End Property

Public Property Itens() As ListItemCollection

Get

If Not IsNothing(viewstate("FirstTime")) Then

Return viewstate("Itens")

Else

Dim lstCol As New ListItemCollection

Dim lst As ListItem

lst = New ListItem("ASP.NET", 0)

lstCol.Add(lst)

lst = New ListItem("ASP", 0)

lstCol.Add(lst)

viewstate("FirstTime") = ""

Return lstCol

End If

End Get

Set(ByVal Value As ListItemCollection)

viewstate("Itens") = Value

End Set

End Property



Protected Overrides Sub Render(ByVal output As System.Web.UI.HtmlTextWriter)

MyBase.Render(output)

End Sub

End Class
 
Hello, I already put the code below my first question...

I'm trying to build a composite control...

The problem is I don't know how to do to make a ListItemControl attached to
the control...Which default value I am supposed to use?

Thanks,

Raphaël...


Juno said:
Hi,

Could you post the code that create the contorl?

--
Juno
MCSD.NET, MCDBA, MCSE
----------------------------------------------------------
Support Team of EasyDotNet, INC. http://www.EasyDotNet.com
DataForm.NET - The most powerful data entry web server control for ASP.NET



Raphaël Désalbres said:
Hello, everybody,

I'm having a problem creating a control...All I want to do is a simple poll
system, so I need to input (trough a ListitemCollection) the values from the
user.

The problem is I'm getting an error each time I try to modify the elements,
I don't know why....

If anyone can help, I would appreciate...

Raphaël...







Imports System.ComponentModel

Imports System.Web.UI

Imports System.Web.UI.WebControls

<DefaultProperty("Text"), ToolboxData("<{0}:WebCustomControl1
runat=server></{0}:WebCustomControl1>")> Public Class WebCustomControl1

Inherits System.Web.UI.WebControls.WebControl

Dim _text As String

<Bindable(True), Category("Appearance"), DefaultValue("")> Property [Text]()
As String

Get

Return _text

End Get

Set(ByVal Value As String)

_text = Value

End Set

End Property

Public Property Itens() As ListItemCollection

Get

If Not IsNothing(viewstate("FirstTime")) Then

Return viewstate("Itens")

Else

Dim lstCol As New ListItemCollection

Dim lst As ListItem

lst = New ListItem("ASP.NET", 0)

lstCol.Add(lst)

lst = New ListItem("ASP", 0)

lstCol.Add(lst)

viewstate("FirstTime") = ""

Return lstCol

End If

End Get

Set(ByVal Value As ListItemCollection)

viewstate("Itens") = Value

End Set

End Property



Protected Overrides Sub Render(ByVal output As System.Web.UI.HtmlTextWriter)

MyBase.Render(output)

End Sub

End Class
 
Hi,

:)I didn't see your code.

I think you may add ListItem to controls and a ListItemCollection instance
in CreateChildControls method .
like:

private lstCol As New ListItemCollection
sub CreateChildControls


Dim lst As ListItem

lst = New ListItem("ASP.NET", 0)
controls.add(1st)
lstCol.Add(lst)

lst = New ListItem("ASP", 0)
controls.add(1st)
lstCol.Add(lst)

end sub


If you'd like to create a listcontrol ,you can inherit
System.Web.UI.WebControls.ListControl.

--
Juno
MCSD.NET, MCDBA, MCSE
----------------------------------------------------------
Support Team of EasyDotNet, INC. http://www.EasyDotNet.com
DataForm.NET - The most powerful data entry web server control for ASP.NET



Raphaël Désalbres said:
Hello, I already put the code below my first question...

I'm trying to build a composite control...

The problem is I don't know how to do to make a ListItemControl attached to
the control...Which default value I am supposed to use?

Thanks,

Raphaël...


Juno said:
Hi,

Could you post the code that create the contorl?

--
Juno
MCSD.NET, MCDBA, MCSE
----------------------------------------------------------
Support Team of EasyDotNet, INC. http://www.EasyDotNet.com
DataForm.NET - The most powerful data entry web server control for ASP.NET



Raphaël Désalbres said:
Hello, everybody,

I'm having a problem creating a control...All I want to do is a simple poll
system, so I need to input (trough a ListitemCollection) the values
from
the
user.

The problem is I'm getting an error each time I try to modify the elements,
I don't know why....

If anyone can help, I would appreciate...

Raphaël...







Imports System.ComponentModel

Imports System.Web.UI

Imports System.Web.UI.WebControls

<DefaultProperty("Text"), ToolboxData("<{0}:WebCustomControl1
runat=server></{0}:WebCustomControl1>")> Public Class WebCustomControl1

Inherits System.Web.UI.WebControls.WebControl

Dim _text As String

<Bindable(True), Category("Appearance"), DefaultValue("")> Property [Text]()
As String

Get

Return _text

End Get

Set(ByVal Value As String)

_text = Value

End Set

End Property

Public Property Itens() As ListItemCollection

Get

If Not IsNothing(viewstate("FirstTime")) Then

Return viewstate("Itens")

Else

Dim lstCol As New ListItemCollection

Dim lst As ListItem

lst = New ListItem("ASP.NET", 0)

lstCol.Add(lst)

lst = New ListItem("ASP", 0)

lstCol.Add(lst)

viewstate("FirstTime") = ""

Return lstCol

End If

End Get

Set(ByVal Value As ListItemCollection)

viewstate("Itens") = Value

End Set

End Property



Protected Overrides Sub Render(ByVal output As System.Web.UI.HtmlTextWriter)

MyBase.Render(output)

End Sub

End Class
 
Hello,

Couldn 't you please send me some more sample code?

Thanks,

Raphaël...


Juno said:
Hi,

:)I didn't see your code.

I think you may add ListItem to controls and a ListItemCollection instance
in CreateChildControls method .
like:

private lstCol As New ListItemCollection
sub CreateChildControls


Dim lst As ListItem

lst = New ListItem("ASP.NET", 0)
controls.add(1st)
lstCol.Add(lst)

lst = New ListItem("ASP", 0)
controls.add(1st)
lstCol.Add(lst)

end sub


If you'd like to create a listcontrol ,you can inherit
System.Web.UI.WebControls.ListControl.

--
Juno
MCSD.NET, MCDBA, MCSE
----------------------------------------------------------
Support Team of EasyDotNet, INC. http://www.EasyDotNet.com
DataForm.NET - The most powerful data entry web server control for ASP.NET



Raphaël Désalbres said:
Hello, I already put the code below my first question...

I'm trying to build a composite control...

The problem is I don't know how to do to make a ListItemControl attached to
the control...Which default value I am supposed to use?

Thanks,

Raphaël...


Juno said:
Hi,

Could you post the code that create the contorl?

--
Juno
MCSD.NET, MCDBA, MCSE
----------------------------------------------------------
Support Team of EasyDotNet, INC. http://www.EasyDotNet.com
DataForm.NET - The most powerful data entry web server control for ASP.NET



Hello, everybody,

I'm having a problem creating a control...All I want to do is a simple
poll
system, so I need to input (trough a ListitemCollection) the values from
the
user.

The problem is I'm getting an error each time I try to modify the
elements,
I don't know why....

If anyone can help, I would appreciate...

Raphaël...







Imports System.ComponentModel

Imports System.Web.UI

Imports System.Web.UI.WebControls

<DefaultProperty("Text"), ToolboxData("<{0}:WebCustomControl1
runat=server></{0}:WebCustomControl1>")> Public Class WebCustomControl1

Inherits System.Web.UI.WebControls.WebControl

Dim _text As String

<Bindable(True), Category("Appearance"), DefaultValue("")> Property
[Text]()
As String

Get

Return _text

End Get

Set(ByVal Value As String)

_text = Value

End Set

End Property

Public Property Itens() As ListItemCollection

Get

If Not IsNothing(viewstate("FirstTime")) Then

Return viewstate("Itens")

Else

Dim lstCol As New ListItemCollection

Dim lst As ListItem

lst = New ListItem("ASP.NET", 0)

lstCol.Add(lst)

lst = New ListItem("ASP", 0)

lstCol.Add(lst)

viewstate("FirstTime") = ""

Return lstCol

End If

End Get

Set(ByVal Value As ListItemCollection)

viewstate("Itens") = Value

End Set

End Property



Protected Overrides Sub Render(ByVal output As
System.Web.UI.HtmlTextWriter)

MyBase.Render(output)

End Sub

End Class
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top