Developing a Wonderful ASP.NET TextField Control - Developing your own flexible Textbox control with new features: coding properties
(Page 4 of 4 )
The coding for the properties is very simple and easy to understand. The following is the entire code for all the properties mentioned in the skeleton:
<EditorBrowsable(EditorBrowsableState.Always), _
DesignerSerializationVisibility(DesignerSerializationVisibility.Visible), _
Bindable(True), Browsable(True), Category("Common")> _
Public Property Text() As String
Get
Return Me.txtControl.Text
End Get
Set(ByVal Value As String)
Me.txtControl.Text = Value
Me.lblControl.Text = Value
End Set
End Property
<Category("Common")> _
Public Property MaxLength() As Integer
Get
Return Me.txtControl.MaxLength
End Get
Set(ByVal value As Integer)
Me.txtControl.Columns = value
Me.txtControl.MaxLength = value
End Set
End Property
<Category("Common")> _
Public Property ErrorText() As String
Get
Return m_strErrorText
End Get
Set(ByVal Value As String)
Me.reqfValidator.ErrorMessage = Value & " is required."
m_strErrorText = Value
End Set
End Property
<Category("Common")> _
Public Property Editable() As Boolean
Get
Return Me.txtControl.Visible
End Get
Set(ByVal Value As Boolean)
If Editable <> Value Then
If Editable Then
lblControl.Text = Me.txtControl.Text
End If
lblControl.Visible = Not Value
txtControl.Visible = Value
reqfValidator.Enabled = Value And Required
spnRequiredIndicator.Visible = Value And Required
End If
End Set
End Property
<Category("Common")> _
Public Property Required() As Boolean
Get
Return m_blnRequired
End Get
Set(ByVal Value As Boolean)
reqfValidator.Enabled = Editable And Value
spnRequiredIndicator.Visible = Editable And Value
m_blnRequired = Value
End Set
End Property
<Category("Field Text")> _
Public Property LabelTextValue() As String
Get
Return Me.lblText.Text
End Get
Set(ByVal value As String)
Me.lblText.Text = value
End Set
End Property
<Category("Field Text")> _
Public Property LabelTextAlign() As System.Web.UI.WebControls.HorizontalAlign
Get
Return pnlText.HorizontalAlign
End Get
Set(ByVal Value As System.Web.UI.WebControls.HorizontalAlign)
pnlText.HorizontalAlign = Value
End Set
End Property
<Category("Field Text")> _
Public Property LabelTextVisible() As Boolean
Get
Return Me.pnlText.Visible
End Get
Set(ByVal Value As Boolean)
Me.pnlText.Visible = Value
End Set
End Property
<Category("Field Text")> _
Public Property LabelTextWidth() As System.Web.UI.WebControls.Unit|
Get
Return pnlText.Width
End Get
Set(ByVal Value As System.Web.UI.WebControls.Unit)
pnlText.Width = Value
End Set
End Property
Developing your own flexible Textbox control with new features: coding properties continued
The following is the continuation of the previous section for the entire code for all of the properties mentioned in the skeleton:
Public Property AutoPostBack() As Boolean
Get
Return txtControl.AutoPostBack()
End Get
Set(ByVal Value As Boolean)
txtControl.AutoPostBack = Value
End Set
End Property
<Category("Appearance")> _
Public Property CssClassTextBoxControl() As String
Get
Return txtControl.CssClass
End Get
Set(ByVal Value As String)
txtControl.CssClass = Value
End Set
End Property
<Category("Appearance")> _
Public Property CssClassLabelControl() As String
Get
Return Me.lblControl.CssClass
End Get
Set(ByVal value As String)
Me.lblControl.CssClass = value
End Set
End Property
<Category("Appearance")> _
Public Property CssClassLabelText() As String
Get
Return Me.lblText.CssClass
End Get
Set(ByVal value As String)
Me.lblText.CssClass = value
End Set
End Property
<Category("Appearance")> _
Public Property Tooltip() As String
Get
Return pnlControl.ToolTip
End Get
Set(ByVal Value As String)
pnlControl.ToolTip = Value
End Set
End Property
Public Property ValidationGroup() As String
Get
Return Me.txtControl.ValidationGroup
End Get
Set(ByVal value As String)
Me.txtControl.ValidationGroup = value
Me.reqfValidator.ValidationGroup = value
End Set
End Property
Public Property HintMessage() As String
Get
Return Me.lblHint.Text
End Get
Set(ByVal value As String)
Me.lblHint.Text = value
End Set
End Property
Public Property HintMessageVisible() As Boolean
Get
Return Me.pnlHint.Visible
End Get
Set(ByVal value As Boolean)
Me.pnlHint.Visible = value
End Set
End Property
I hope you enjoyed this article. Any suggestions, bugs, errors, enhancements etc. are highly appreciated at http://jagchat.spaces.live.com
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |