locked
Custom Drop Down Server Control - "Error Creating Control" RRS feed

  • Question

  • User1537915142 posted

    I'm getting this error in the designer for this custom control.
    "Error creating control,'true' could not be set on property 'Insert Blank Line'

    Here is the code, any suggestions?

    <cc1:UnitedStatesDropDownList ID="ddlStates" runat="server" CssClass="input" InsertBlankLine="true" />

    Option Strict On
    Option Explicit On
    
    Imports System.Web.UI
    Imports System.Collections.Specialized
    Imports System.ComponentModel
    
    Namespace UI.WebControls
    
        <ToolboxData("<{0}:UnitedStatesDropDownList runat=server></{0}:UnitedStatesDropDownList>")> _
        Public Class UnitedStatesDropDownList
            Inherits System.Web.UI.WebControls.DropDownList
    
            Private _states() As String = New String() {"Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut", "Delaware", "District of Columbia", "Florida", "Georgia", "Hawaii", "Idaho", "Illinois", "Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana", "Maine", "Maryland", "Massachusetts", "Michigan", "Minnesota", "Mississippi", "Missouri", "Montana", "Nebraska", "Nevada", "New Hampshire", "New Jersey", "New Mexico", "New York", "North Carolina", "North Dakota", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island", "South Carolina", "South Dakota", "Tennessee", "Texas", "Utah", "Vermont", "Virginia", "Washington", "West Virginia", "Wisconsin", "Wyoming"}
            Private _insertBlankLine As Boolean
    
            <Browsable(True), Category("Appearance"), _
             DefaultValue("false"), _
             Description("Inserts a blank line into the first index")> _
             Public Property InsertBlankLine() As Boolean
                Get
                    If ViewState("InsertBlankLine") Is Nothing Then
                        Return False
                    Else
                        Return Convert.ToBoolean(ViewState("InsertBlankLine"))
                    End If
                End Get
                Set(ByVal value As Boolean)
                    ViewState("InsertBlankLine") = value
                End Set
            End Property
    
            Private Sub UnitedStatesDropDownList_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
                Me.DataSource = GetStatesOfAmerica()
                Me.DataBind()
    
                If Me.InsertBlankLine Then
                    Me.Items.Insert(0, String.Empty)
                End If
    
            End Sub
    
            Public Function GetStatesOfAmerica() As StringCollection
                Dim sc As New StringCollection
                sc.AddRange(_states)
                Return sc
            End Function
    
            Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)
                If DesignMode Then
                    writer.Write("<select style='width:200px'><option>United States of America</option></select>")
                    Exit Sub
                End If
                MyBase.Render(writer)
            End Sub
    
        End Class
    
    
    End Namespace
    


    Saturday, March 27, 2010 8:27 AM

All replies

  • User-1360095595 posted

    Could it be the InsertBlankLine="true"is not recognised, and you need to use True, case sensitive? 

    Saturday, March 27, 2010 7:51 PM
  • User1537915142 posted

    I dont think it is case sensative. When I typed in the aspx file, the intelisense opened up and true was lower case.

    I just opened visual studio (had it closed all day) and it is not giving me the error message now.


    Saturday, March 27, 2010 8:01 PM