F
Francois Soucy
Hi all!
I've begin my first webcontrol with asp.net. I've not build
everything but the first part is done except that the dropdownlist did not
keep is selected value between postback. I've reed many tutorial but no one
can explain me what's wrong with my code. Someone could give me a little
help?
Thanks,
Francois
######
Public Class RssControl
Inherits Panel
Implements INamingContainer
Protected CboRssDrop As New DropDownList
Private _DataTextField As String
Private _DataValueField As String
Private _DataSource As Object
#Region "Property"
Public Property DataTextField() As String
Get
Return Me._DataTextField
End Get
Set(ByVal Value As String)
Me._DataTextField = Value
Me.CboRssDrop.DataTextField = Value
End Set
End Property
Public Property DataValueField() As String
Get
Return Me._DataValueField
End Get
Set(ByVal Value As String)
Me._DataValueField = Value
Me.CboRssDrop.DataValueField = Value
End Set
End Property
Public Property DataSource() As Object
Get
Return Me._DataSource
End Get
Set(ByVal Value As Object)
Me._DataSource = Value
Me.CboRssDrop.DataSource = Value
End Set
End Property
#End Region
#Region "DataBind"
Public Overrides Sub DataBind()
Me.CboRssDrop.DataBind()
End Sub
#End Region
#Region "OnInit"
Protected Overrides Sub OnInit(ByVal e As EventArgs)
Me.CboRssDrop.AutoPostBack = True
Me.CboRssDrop.EnableViewState = True
MyBase.OnInit(e)
End Sub 'OnInit
#End Region
#Region "CreateChildCtl"
Protected Overrides Sub CreateChildControls()
Me.AfficherControl()
End Sub 'CreateChildControls
#End Region
#Region "AfficherCtl"
Protected Sub AfficherControl()
Me.Controls.Add(New LiteralControl("<table class=""Article""
cellSpacing=""0"" cellPadding=""0"" width=""240"" border=""0"">"))
Me.Controls.Add(New LiteralControl("<TR><TD
Class=""ArticleTitre"">"))
Me.CboRssDrop.Width = Unit.Percentage(90)
Me.Controls.Add(Me.CboRssDrop)
Me.Controls.Add(New LiteralControl("</td></TR><tr><td
class=""ArticleTexte"">###Text###</td></TR>"))
Me.Controls.Add(New LiteralControl("<TR><td
class=""ArticleSignature"">###SIGNATURE###</td></TR>"))
Me.Controls.Add(New LiteralControl("</TABLE>"))
Me.Controls.Add(New LiteralControl("<table class=""deco1""
cellSpacing=""0"" cellPadding=""0"" width=""200"" align=""center""
border=""0"">"))
Me.Controls.Add(New
LiteralControl("<TR><TD> </TD></TR></TABLE>"))
End Sub
#End Region
End Class
I've begin my first webcontrol with asp.net. I've not build
everything but the first part is done except that the dropdownlist did not
keep is selected value between postback. I've reed many tutorial but no one
can explain me what's wrong with my code. Someone could give me a little
help?
Thanks,
Francois
######
Public Class RssControl
Inherits Panel
Implements INamingContainer
Protected CboRssDrop As New DropDownList
Private _DataTextField As String
Private _DataValueField As String
Private _DataSource As Object
#Region "Property"
Public Property DataTextField() As String
Get
Return Me._DataTextField
End Get
Set(ByVal Value As String)
Me._DataTextField = Value
Me.CboRssDrop.DataTextField = Value
End Set
End Property
Public Property DataValueField() As String
Get
Return Me._DataValueField
End Get
Set(ByVal Value As String)
Me._DataValueField = Value
Me.CboRssDrop.DataValueField = Value
End Set
End Property
Public Property DataSource() As Object
Get
Return Me._DataSource
End Get
Set(ByVal Value As Object)
Me._DataSource = Value
Me.CboRssDrop.DataSource = Value
End Set
End Property
#End Region
#Region "DataBind"
Public Overrides Sub DataBind()
Me.CboRssDrop.DataBind()
End Sub
#End Region
#Region "OnInit"
Protected Overrides Sub OnInit(ByVal e As EventArgs)
Me.CboRssDrop.AutoPostBack = True
Me.CboRssDrop.EnableViewState = True
MyBase.OnInit(e)
End Sub 'OnInit
#End Region
#Region "CreateChildCtl"
Protected Overrides Sub CreateChildControls()
Me.AfficherControl()
End Sub 'CreateChildControls
#End Region
#Region "AfficherCtl"
Protected Sub AfficherControl()
Me.Controls.Add(New LiteralControl("<table class=""Article""
cellSpacing=""0"" cellPadding=""0"" width=""240"" border=""0"">"))
Me.Controls.Add(New LiteralControl("<TR><TD
Class=""ArticleTitre"">"))
Me.CboRssDrop.Width = Unit.Percentage(90)
Me.Controls.Add(Me.CboRssDrop)
Me.Controls.Add(New LiteralControl("</td></TR><tr><td
class=""ArticleTexte"">###Text###</td></TR>"))
Me.Controls.Add(New LiteralControl("<TR><td
class=""ArticleSignature"">###SIGNATURE###</td></TR>"))
Me.Controls.Add(New LiteralControl("</TABLE>"))
Me.Controls.Add(New LiteralControl("<table class=""deco1""
cellSpacing=""0"" cellPadding=""0"" width=""200"" align=""center""
border=""0"">"))
Me.Controls.Add(New
LiteralControl("<TR><TD> </TD></TR></TABLE>"))
End Sub
#End Region
End Class