I am facing a problem with the Font property of my Composite Custom Web Control.
I have built a composite control with textboxes, labels and buttons.
Following are the code and the error details:
Private _loginidlabelfont As Font
'Other code
Public Property LoginIdLabelFont() As Font
Get
Return _loginidlabelfont
End Get
Set(ByVal Value As Font)
_loginidlabelfont = Value
End Set
End Property
'Other code
Protected Overrides Sub CreateChildControls()
'Other Code
Dim lblLoginId As New Label()
lblLoginId.Text = _loginidlabel
lblLoginId.BackColor = _labelbackcolor
lblLoginId.ForeColor = _labelforecolor
lblLoginId.Font.Name = _loginidlabelfont.Name
lblLoginId.Font.Bold = _loginidlabelfont.Bold
lblLoginId.Font.Italic = _loginidlabelfont.Italic
lblLoginId.Font.Underline = _loginidlabelfont.Underline
lblLoginId.Font.Size = convertfont.Point(_loginidlabelfont.Size)
'Other Code
Now I am using the composite control in a Web Application.
In the property sheet for the control I get the LoginIdLabelFont() property.
The problem comes when I select multiple styles (Bold, Underline, Italic, Strikeout).
If I select only one of them, it works fine. But, If I select any 2 or more then it gives me an error message:
-----------------------------------------------------------------------------
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
-----------------------------------------------------------------------------
Can anybody help me with this?
BR,
Bans.