?
Solved

Error in a web custom control from properties using classes

Posted on 2007-07-26
4
Medium Priority
?
1,462 Views
Last Modified: 2010-05-18
HI,

I'm building a custom web control and it was working fine unitl I've added a new nested property derived from a class. The property is Sql and it shows connection ans script properties.

It work well in the designer browser but I get the following message in the designer and at runtime:
HQFilter1:You cannot use HQ.HQFilter's default collection 'FilterColumns' without the property tags when using a filtered version of the same collection.

I use two classes as properties in that control and that's probably my problem, I probably have to do something to be able to use the two classes but I don't know how.

Here's the complete control's code:

Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Text
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.drawing


<PersistChildren(False), ParseChildren(True, "FilterColumns"), Designer(GetType(HQFilterDesigner))> _
Public Class HQFilter
    Inherits WebControl


#Region "Init"

    Private WithEvents grd As New Infragistics.WebUI.UltraWebGrid.UltraWebGrid
    Private _FltColumns As ColCollection = New ColCollection
    Private _Sortcol As FltColumn
    Private _indexcol As FltColumn
    Private sqlC As New Sql


    Private imgSearch, imgSearchH, imgBack, imgExpand, imgExpandH, imgColl, imgCollH As String
    Private ds As DataSet



    Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)


        'Traitement Ajax

        If Not IsNothing(Page.Request("q")) Then
            Dim strQuery As String = Page.Request("q").ToString()
            Dim strFnc As String = Split(strQuery, "~")(0)
            If strFnc = "GoSql" Then
                'Page.Response.Write("HI!")
                Dim rFound As DataRow() = ds.Tables(0).Select("inc_seq = 10")
                grd.DataSource = ds
                grd.DataBind()

            End If
        End If



    End Sub
    Protected Overrides Sub OnInit(ByVal e As System.EventArgs)


        'A l'initialisation de la page on enregistre les scripts et les images

        Dim scriptLocation As String = Page.ClientScript.GetWebResourceUrl(Me.GetType(), "HQ.HQFilter.js")
        Page.ClientScript.RegisterClientScriptInclude("HQ.HQFilter.js", scriptLocation)
        scriptLocation = Page.ClientScript.GetWebResourceUrl(Me.GetType(), "HQ.HQAjax.js")
        Page.ClientScript.RegisterClientScriptInclude("HQ.HQAjax.js", scriptLocation)

        imgSearch = Page.ClientScript.GetWebResourceUrl(Me.GetType(), "HQ.search.jpg")
        imgSearchH = Page.ClientScript.GetWebResourceUrl(Me.GetType(), "HQ.search_h.jpg")
        imgBack = Page.ClientScript.GetWebResourceUrl(Me.GetType(), "HQ.HitList_back.png")
        imgExpand = Page.ClientScript.GetWebResourceUrl(Me.GetType(), "HQ.Expand.png")
        imgExpandH = Page.ClientScript.GetWebResourceUrl(Me.GetType(), "HQ.Expand_h.png")
        imgColl = Page.ClientScript.GetWebResourceUrl(Me.GetType(), "HQ.collapse.png")
        imgCollH = Page.ClientScript.GetWebResourceUrl(Me.GetType(), "HQ.collapse_h.png")



        MyBase.OnInit(e)
        EnsureChildControls()

    End Sub

    Protected Overrides Sub Render(ByVal writer As HtmlTextWriter)


        Dim strHTML As String = My.Resources.Search
        'Identification du popup
        strHTML = Replace(strHTML, "divPop", Me.ID & "_search")
        strHTML = Replace(strHTML, "testSql();", "goSql('" & Page.Request.Url.ToString & "','" & Me.ID & "');")

        writer.Write(strHTML)

        'Dim strAjax As String = My.Resources.Ajax
        'writer.Write(strAjax)


        writer.RenderBeginTag("div runat=""server"" class=""HQFilter"" id='jsObj_" & Me.ID & "' name='jsObj_" & Me.ID & "'")
        writer.Write(("<script language=""javascript"">initFilter('" & Me.ID & "');</script>") & vbCr)

        MyBase.Render(writer)
        writer.RenderEndTag()







    End Sub

#End Region

#Region "Hidden properties"

    <Browsable(False), EditorBrowsable(EditorBrowsableState.Never)> _
        Public Overrides Property AccessKey() As String
        Get
            Return MyBase.AccessKey
        End Get
        Set(ByVal value As String)
            MyBase.AccessKey = value
        End Set
    End Property
    <Browsable(False), EditorBrowsable(EditorBrowsableState.Never)> _
    Public Overrides Property BackColor() As System.Drawing.Color
        Get
            Return MyBase.BackColor
        End Get
        Set(ByVal value As System.Drawing.Color)
            MyBase.BackColor = value
        End Set
    End Property
    <Browsable(False), EditorBrowsable(EditorBrowsableState.Never)> _
    Public Overrides Property BorderColor() As System.Drawing.Color
        Get
            Return MyBase.BorderColor
        End Get
        Set(ByVal value As System.Drawing.Color)
            MyBase.BorderColor = value
        End Set
    End Property
    <Browsable(False), EditorBrowsable(EditorBrowsableState.Never)> _
    Public Overrides Property BorderStyle() As System.Web.UI.WebControls.BorderStyle
        Get
            Return MyBase.BorderStyle
        End Get
        Set(ByVal value As System.Web.UI.WebControls.BorderStyle)
            MyBase.BorderStyle = value
        End Set
    End Property
    <Browsable(False), EditorBrowsable(EditorBrowsableState.Never)> _
    Public Overrides Property BorderWidth() As System.Web.UI.WebControls.Unit
        Get
            Return MyBase.BorderWidth
        End Get
        Set(ByVal value As System.Web.UI.WebControls.Unit)
            MyBase.BorderWidth = value
        End Set
    End Property
    <Browsable(False), EditorBrowsable(EditorBrowsableState.Never)> _
    Public Overrides Property CssClass() As String
        Get
            Return MyBase.CssClass
        End Get
        Set(ByVal value As String)
            MyBase.CssClass = value
        End Set
    End Property
    <Browsable(False), EditorBrowsable(EditorBrowsableState.Never)> _
    Public Overrides Property EnableTheming() As Boolean
        Get
            Return MyBase.EnableTheming
        End Get
        Set(ByVal value As Boolean)
            MyBase.EnableTheming = value
        End Set
    End Property
    <Browsable(False), EditorBrowsable(EditorBrowsableState.Never)> _
    Public Overrides ReadOnly Property Font() As System.Web.UI.WebControls.FontInfo
        Get
            Return MyBase.Font
        End Get
    End Property
    <Browsable(False), EditorBrowsable(EditorBrowsableState.Never)> _
    Public Overrides Property ForeColor() As System.Drawing.Color
        Get
            Return MyBase.ForeColor
        End Get
        Set(ByVal value As System.Drawing.Color)
            MyBase.ForeColor = value
        End Set
    End Property
    <Browsable(False), EditorBrowsable(EditorBrowsableState.Never)> _
    Public Overrides Property Height() As System.Web.UI.WebControls.Unit
        Get
            Return MyBase.Height
        End Get
        Set(ByVal value As System.Web.UI.WebControls.Unit)
            MyBase.Height = value
        End Set
    End Property
    <Browsable(False), EditorBrowsable(EditorBrowsableState.Never)> _
    Public Overrides Property SkinID() As String
        Get
            Return MyBase.SkinID
        End Get
        Set(ByVal value As String)
            MyBase.SkinID = value
        End Set
    End Property
    <Browsable(False), EditorBrowsable(EditorBrowsableState.Never)> _
    Public Overrides Property Width() As System.Web.UI.WebControls.Unit
        Get
            Return MyBase.Width
        End Get
        Set(ByVal value As System.Web.UI.WebControls.Unit)
            MyBase.Width = value
        End Set
    End Property



#End Region

#Region "Properties"

    Public Enum Expansion
        ScrollBar = 0
        Expand = 1
    End Enum

    <PersistenceMode(PersistenceMode.InnerDefaultProperty), _
      DesignerSerializationVisibility(DesignerSerializationVisibility.Content)> _
    Public ReadOnly Property [FilterColumns]() As ColCollection
        Get
            Return _FltColumns
        End Get
    End Property
    <DefaultValue(""), Category("Custom"), _
        PersistenceMode(PersistenceMode.InnerProperty), _
        DesignerSerializationVisibility(DesignerSerializationVisibility.Content), _
        Description("Information de connection SQL")> _
        Property [SqlConnection]() As Sql
        Get
            Return sqlC
        End Get
        Set(ByVal value As Sql)
            sqlC = value
        End Set
    End Property


    '<Description("Script SQL pour lire les données de la grille")> _
    '         Property SqlScript() As String
    '    Get
    '        Dim o As Object = ViewState("SqlScript")
    '        If o Is Nothing Then
    '            Return ""
    '        End If
    '        Return CType(ViewState("SqlScript"), String)
    '    End Get
    '    Set(ByVal Value As String)
    '        ViewState("SqlScript") = Value

    '    End Set
    'End Property
    '<Category("Connection"), PasswordPropertyText(True), Description("Mot de passe pour connection a SQL si l'authentification windows n'est pas utilisé")> _
    '        Property SqlPsw() As String
    '    Get
    '        Dim o As Object = ViewState("SqlPsw")
    '        If o Is Nothing Then
    '            Return ""
    '        End If
    '        Return CType(ViewState("SqlPsw"), String)
    '    End Get
    '    Set(ByVal Value As String)
    '        ViewState("SqlPsw") = Value

    '    End Set
    'End Property
    '<Category("Connection"), Description("Utilisateur pour connection a SQL si l'authentification windows n'est pas utilisé")> _
    '       Property SqlUser() As String
    '    Get
    '        Dim o As Object = ViewState("SqlUser")
    '        If o Is Nothing Then
    '            Return ""
    '        End If
    '        Return CType(ViewState("SqlUser"), String)
    '    End Get
    '    Set(ByVal Value As String)
    '        ViewState("SqlUser") = Value

    '    End Set
    'End Property
    <Description("Nombre de ligne par page dans la grille")> _
          Property PageSize() As Integer
        Get
            Dim o As Object = ViewState("PageSize")
            If o Is Nothing Then
                Return 25
            End If
            Return CType(ViewState("PageSize"), Integer)
        End Get
        Set(ByVal Value As Integer)
            ViewState("PageSize") = Value

        End Set
    End Property
    <Description("Largeur de la grille en expansion")> _
       Property ExpandSize() As Integer
        Get
            Dim o As Object = ViewState("ExpandSize")
            If o Is Nothing Then
                Return 200
            End If
            Return CType(ViewState("ExpandSize"), Integer)
        End Get
        Set(ByVal Value As Integer)
            ViewState("ExpandSize") = Value

        End Set
    End Property
    <Description("Hauteur du controle de filtre")> _
    Property FilterHeight() As Integer
        Get
            Dim o As Object = ViewState("FFHeight")
            If o Is Nothing Then
                Return 200
            End If
            Return CType(ViewState("FFHeight"), Integer)
        End Get
        Set(ByVal Value As Integer)
            ViewState("FFHeight") = Value

        End Set
    End Property
    <Description("Largeur du controle de filtre")> _
    Property FilterWidth() As Integer
        Get
            Dim o As Object = ViewState("FFWidth")
            If o Is Nothing Then
                Return 200
            End If
            Return CType(ViewState("FFWidth"), Integer)
        End Get
        Set(ByVal Value As Integer)
            ViewState("FFWidth") = Value

        End Set
    End Property

    <Description("Affichage de la barre déroulante horizontale")> _
   Property GridNavigation() As Expansion
        Get
            Dim o As Object = ViewState("GridNavigation")
            If o Is Nothing Then
                Return Expansion.Expand
            End If
            Return CType(ViewState("GridNavigation"), Expansion)
        End Get
        Set(ByVal Value As Expansion)
            ViewState("GridNavigation") = Value

        End Set
    End Property



#End Region

#Region "Constructors"


    Private Function CreateCol() As Integer
        grd.Height = Me.FilterHeight - 45
        grd.Width = Me.FilterWidth


        Dim intIndex As Integer = 0
        For Each fltc As FltColumn In Me.FilterColumns
            If fltc.Indexed Then intIndex = intIndex + 1
        Next
        If intIndex > 1 Then
            Return 1
        End If

        If Me.FilterColumns.Count = 0 Then Return 2

        Dim cc As Infragistics.WebUI.UltraWebGrid.UltraGridColumn

        For Each fltc As FltColumn In Me.FilterColumns
            For Each c As DataColumn In ds.Tables(0).Columns
                If fltc.Key = c.ColumnName Then
                    If IsNothing(grd.Columns.FromKey(fltc.Key)) Then
                        cc = New Infragistics.WebUI.UltraWebGrid.UltraGridColumn
                        grd.Columns.Add(cc)
                    Else
                        cc = grd.Columns.FromKey(fltc.Key)
                    End If

                    With cc

                        If fltc.Sorted Then
                            .SortIndicator = Infragistics.WebUI.UltraWebGrid.SortIndicator.Ascending
                        End If
                        .Key = fltc.Key
                        .Width = fltc.ColWidth
                        .Hidden = Not fltc.VisibleInFilter
                        .BaseColumnName = fltc.Key
                        .Header.Caption = fltc.Header
                        .Header.Style.HorizontalAlign = fltc.HeaderAlign
                        If fltc.HeaderAlign <> HorizontalAlign.Center Then
                            .Header.Style.Padding.Left = Unit.Pixel(10)
                        End If
                        .CellStyle.HorizontalAlign = fltc.CellAlign
                        If fltc.CellAlign <> HorizontalAlign.Center Then
                            .CellStyle.Padding.Left = Unit.Pixel(10)
                        End If

                    End With



                End If
            Next
        Next

        Return 0
    End Function
    Private Sub grd_InitializeLayout(ByVal sender As Object, ByVal e As Infragistics.WebUI.UltraWebGrid.LayoutEventArgs) Handles grd.InitializeLayout

    End Sub
    Private Sub grd_InitializeDataSource(ByVal sender As System.Object, ByVal e As Infragistics.WebUI.UltraWebGrid.UltraGridEventArgs) Handles grd.InitializeDataSource


        Dim strErr As String = ""
        If IsNothing(System.Configuration.ConfigurationManager.AppSettings.Item("serveur")) Then
            strErr = "Paramètre SERVEUR dans webconfig inexistant ou erroné"
            GoTo RenderErr
        End If
        If IsNothing(System.Configuration.ConfigurationManager.AppSettings.Item("base")) Then
            strErr = "Paramètre BASE dans webconfig inexistant ou erroné"
            GoTo RenderErr
        End If
        If IsNothing(System.Configuration.ConfigurationManager.AppSettings.Item("timeout")) Then
            strErr = "Paramètre TIMEOUT dans webconfig inexistant ou erroné"
            GoTo RenderErr
        End If
        If IsNothing(System.Configuration.ConfigurationManager.AppSettings.Item("MinPoolSize")) Then
            strErr = "Paramètre MINPOOLSIZE dans webconfig inexistant ou erroné"
            GoTo RenderErr
        End If
        If IsNothing(System.Configuration.ConfigurationManager.AppSettings.Item("MaxPoolSize")) Then
            strErr = "Paramètre MAXPOOLSIZE dans webconfig inexistant ou erroné"
            GoTo RenderErr
        End If
        If IsNothing(System.Configuration.ConfigurationManager.AppSettings.Item("environnement")) Then
            strErr = "Paramètre ENVIRONNEMENT dans webconfig inexistant ou erroné"
            GoTo RenderErr
        End If
        If Me.SqlConnection.SqlScript = "" Then
            strErr = "Pas de script SQL, lecture des données impossible"
            GoTo RenderErr
        End If


        Dim objSql As New csSql
        Try
            ds = objSql.GetAllStr(Me.SqlConnection.SqlScript)
        Catch ex As Exception
            strErr = "Erreur d'acces a la base de donnee:" & vbCr & ex.Message
            GoTo RenderErr
        End Try


        Dim dv As DataView = ds.Tables(0).DefaultView



        Select Case CreateCol()
            Case 0
                Dim strSort As String = ""


                If Not Page.IsPostBack Then
                    For Each fltc As FltColumn In Me.FilterColumns
                        For Each c As Infragistics.WebUI.UltraWebGrid.UltraGridColumn In grd.Columns
                            If fltc.Key = c.Key Then
                                If fltc.Sorted Then
                                    strSort = strSort & fltc.Key & ","
                                End If
                            End If
                        Next
                    Next
                    If strSort <> "" Then
                        strSort = Left(strSort, Len(strSort) - 1)
                        dv.Sort = strSort
                    End If


                End If
                grd.DataSource = dv
                grd.DataBind()
            Case 1
                strErr = "Il y a plus d'une colonne indexé"
                GoTo RenderErr
            Case 2
                strErr = "Aucune colonne spécifié"
                GoTo RenderErr
        End Select
        'If CreateCol() = 0 Then
        '    Dim strSort As String = ""


        '    If Not Page.IsPostBack Then
        '        For Each fltc As FltColumn In Me.Columns
        '            For Each c As Infragistics.WebUI.UltraWebGrid.UltraGridColumn In grd.Columns
        '                If fltc.Key = c.Key Then
        '                    If fltc.Sorted Then
        '                        strSort = strSort & fltc.Key & ","
        '                    End If
        '                End If
        '            Next
        '        Next
        '        If strSort <> "" Then
        '            strSort = Left(strSort, Len(strSort) - 1)
        '            dv.Sort = strSort
        '        End If


        '    End If
        '    grd.DataSource = dv
        '    grd.DataBind()
        'Else

        'End If



RenderErr:

        grd.DisplayLayout.NoDataMessage = strErr






    End Sub

    Protected Overloads Overrides Sub CreateChildControls()



        'Bouton de recherche
        Dim imgS As New HtmlControls.HtmlImage
        With imgS
            .Attributes.Add("OnMouseOver", "this.src = '" & imgSearchH & "'")
            .Attributes.Add("OnMouseOut", "this.src = '" & imgSearch & "'")
            .Attributes.Add("OnClick", "Search('" & Me.ID & "_search');")
            .Src = imgSearch
            .Alt = "Ouvrir la fenêtre de recherche"
        End With

        'Cellule qui contient le bouton
        Dim c1Title As New TableCell
        With c1Title
            '.Style.Add("PADDING-LEFT", "10px")
            .Controls.Add(imgS)
        End With

        'Titre
        Dim lblTitle As New Label
        With lblTitle
            .Text = "Filtre de recherche"
            .Font.Name = "Tahoma"
            .Font.Size = 10
            .Font.Bold = True
        End With

        'Cellule qui contient le titre
        Dim c2Title As New TableCell
        With c2Title
            .Controls.Add(lblTitle)
            .HorizontalAlign = HorizontalAlign.Center
        End With

        'Bouton d'expansion
        Dim imgE As New HtmlControls.HtmlImage
        With imgE
            .Attributes.Add("OnMouseOver", "this.src = '" & imgExpandH & "'")
            .Attributes.Add("OnMouseOut", "this.src = '" & imgExpand & "'")
            .Attributes.Add("OnClick", "expandGrd('" & Me.ID & "','" & _
                 Me.ExpandSize & "','" & Me.FilterWidth & "','" & Me.FilterHeight & _
                 "','" & imgExpand & "','" & imgExpandH & "','" & imgColl & "','" & imgCollH & "')")
            .Src = imgExpand
            .Alt = "Elargir la grille"
            .ID = Me.ID & "_img"
        End With

        'Cellule qui contient le bouton expand
        Dim c3Title As New TableCell
        With c3Title
            '.Style.Add("PADDING-LEFT", "10px")
            .HorizontalAlign = HorizontalAlign.Right
            If Me.GridNavigation = Expansion.Expand Then
                .Controls.Add(imgE)
            End If

        End With

        'Rangée du titre et bouton de recherche
        Dim rTitle As New TableRow
        With rTitle
            .BorderWidth = New Unit(0)
            .HorizontalAlign = HorizontalAlign.Left
            .Height = New Unit(20)
            .BackColor = Color.FromName("#aeada0")
            .Cells.Add(c1Title)
            .Cells.Add(c2Title)
            .Cells.Add(c3Title)
        End With




        'Grille de sélection
        With grd
            .Browser = Infragistics.WebUI.UltraWebGrid.BrowserLevel.Xml
            .BackColor = Color.FromArgb(149, 178, 195)
            .ID = Me.ID & "_grd"
            .BorderStyle = WebControls.BorderStyle.Solid
            .BorderWidth = 1
            .BorderColor = Color.Black




            With .DisplayLayout


                If Me.GridNavigation = Expansion.ScrollBar Then
                    .ScrollBar = Infragistics.WebUI.UltraWebGrid.ScrollBar.Auto
                    .ScrollBarView = Infragistics.WebUI.UltraWebGrid.ScrollBarView.Both
                Else
                    .ScrollBar = Infragistics.WebUI.UltraWebGrid.ScrollBar.Auto
                    .ScrollBarView = Infragistics.WebUI.UltraWebGrid.ScrollBarView.Vertical
                End If
                .AutoGenerateColumns = False
                .TableLayout = Infragistics.WebUI.UltraWebGrid.TableLayout.Auto
                .RowSelectorsDefault = Infragistics.WebUI.UltraWebGrid.RowSelectors.No
                .AllowUpdateDefault = Infragistics.WebUI.UltraWebGrid.AllowUpdate.No
                .AllowSortingDefault = Infragistics.WebUI.UltraWebGrid.AllowSorting.OnClient
                .HeaderClickActionDefault = Infragistics.WebUI.UltraWebGrid.HeaderClickAction.SortSingle

                .LoadOnDemand = Infragistics.WebUI.UltraWebGrid.LoadOnDemand.Xml
                .Pager.AllowPaging = True
                .Pager.PageSize = Me.PageSize
                .RowsRange = Me.PageSize
                .Pager.StyleMode = Infragistics.WebUI.UltraWebGrid.PagerStyleMode.Numeric
                .Pager.NextText = "Suivant"
                .Pager.PrevText = "Précédent"


                .CellClickActionDefault = Infragistics.WebUI.UltraWebGrid.CellClickAction.RowSelect
                .RowStyleDefault.BackColor = Drawing.Color.FromArgb(238, 249, 253)
                .RowAlternateStyleDefault.BackColor = Drawing.Color.FromArgb(215, 236, 244)
                .SelectedRowStyleDefault.BackColor = Drawing.Color.FromArgb(255, 204, 51)
                .RowStyleDefault.Font.Size = FontUnit.Point(10)
                .Grid.Font.Name = "Tahoma"
                .Grid.Font.Size = FontUnit.Point(10)
                .ClientSideEvents.DblClickHandler = "LineClick"
                .RowStyleDefault.Height = 20
                .StationaryMargins = Infragistics.WebUI.UltraWebGrid.StationaryMargins.Header

                With .HeaderStyleDefault
                    .Font.Name = "Tahoma"
                    .Font.Size = System.Web.UI.WebControls.FontUnit.Point(10)
                    .Font.Bold = True
                    .BackgroundImage = imgBack
                End With
            End With
        End With




        ''Panel qui contient la grille
        'Dim pnlGrd As New Panel
        'With pnlGrd
        '    .ID = "pnlGrd"
        '    .Controls.Add(grd)
        '    .Style.Add("border-bottom", "black 10px solid")
        '    .Style.Add("border-right", "black 1px solid")
        '    .Style.Add("border-left", "black 1px solid")
        '    .Height = Me.FilterHeight - 20
        '    .Width = Me.FilterWidth
        '    .ScrollBars = ScrollBars.Auto
        'End With


        ''Option d'expansion pour le panel
        'Dim exp As New AjaxControlToolkit.CollapsiblePanelExtender
        'With exp
        '    .AutoCollapse = True
        '    .AutoExpand = True
        '    .Collapsed = True
        '    .CollapsedSize = Me.FilterWidth
        '    .ExpandDirection = AjaxControlToolkit.CollapsiblePanelExpandDirection.Horizontal
        '    .ExpandedSize = 400
        '    .TargetControlID = "pnlGrd"
        'End With


        'Table qui contient le titre
        Dim tbControl As New Table
        With tbControl
            .CellPadding = 0
            .CellSpacing = 0
            .Width = Me.FilterWidth
            .Rows.Add(rTitle)
            .Style.Add("border-top", "black 1px solid")
            .Style.Add("border-right", "black 1px solid")
            .Style.Add("border-left", "black 1px solid")
        End With



        Controls.Add(tbControl)
        Controls.Add(grd)










    End Sub







#End Region

End Class



#Region "Object class"


'Définition des propriétés des colonnes

<DesignTimeVisible(True), ToolboxItem(False)> _
 Public Class FltColumn
    Inherits Control
    Implements INamingContainer


    Dim _ID As String
    Dim _key As String
    Dim _visible As Boolean
    Dim _format As String
    Dim _header As String
    Dim _showinsearch As Boolean
    Dim _searchlabel As String
    Dim _width As Integer
    Dim _headerfmt As WebControls.HorizontalAlign
    Dim _cellfmt As WebControls.HorizontalAlign
    Dim _sort As Boolean
    Dim _index As Boolean



    <Description("Détermine la largeur de la colonne"), Category("Colonne")> _
       Public Property ColWidth() As Integer
        Get

            If _width = 0 Then
                Return 40
            End If
            Return _width
        End Get
        Set(ByVal value As Integer)
            _width = value
        End Set
    End Property
    <Description("Détermine si la colonne est visible dans la grille du filtre"), Category("Grille")> _
    Public Property VisibleInFilter() As Boolean
        Get
            Return _visible
        End Get
        Set(ByVal value As Boolean)
            _visible = value
        End Set
    End Property
    <Description("Détermine la chaine de caractère qui met en forme la colonne dans la grille"), Category("Grille")> _
       Public Property Format() As String
        Get
            Return _format
        End Get
        Set(ByVal value As String)
            _format = value
        End Set
    End Property
    <Description("Alignement horizontal de la colonne"), Category("Grille")> _
          Public Property CellAlign() As WebControls.HorizontalAlign
        Get
            Return _cellfmt
        End Get
        Set(ByVal value As WebControls.HorizontalAlign)
            _cellfmt = value
        End Set
    End Property

    <Description("Le texte qui sera affiché pour l'entête de la colonne dans la grille"), Category("Grille")> _
       Public Property Header() As String
        Get
            Return _header
        End Get
        Set(ByVal value As String)
            _header = value
        End Set
    End Property
    <Description("Alignement horizontal de l'entête"), Category("Grille")> _
       Public Property HeaderAlign() As WebControls.HorizontalAlign
        Get
            Return _headerfmt
        End Get
        Set(ByVal value As WebControls.HorizontalAlign)
            _headerfmt = value
        End Set
    End Property
    <Description("Détermine si la colonne est visible dans la fenêtre de recherche"), Category("Recherche")> _
       Public Property ShowInSearch() As Boolean
        Get
            Return _showinsearch
        End Get
        Set(ByVal value As Boolean)
            _showinsearch = value
        End Set
    End Property
    <Description("Détermine si il y a un tri initial sur cette colonne"), Category("Colonne")> _
      Public Property Sorted() As Boolean
        Get
            Return _sort
        End Get
        Set(ByVal value As Boolean)
            _sort = value
        End Set
    End Property
    <Description("Détermine la clé lorsque qu'une ligne est choisi, une seule colonne doit avoir cet attribut"), Category("Colonne")> _
     Public Property Indexed() As Boolean
        Get
            Return _index
        End Get
        Set(ByVal value As Boolean)
            _index = value
        End Set
    End Property
    <Description("Le texte qui sera affiché dans la fenêtre de recherche"), Category("Recherche")> _
      Public Property SearchLabel() As String
        Get
            Return _searchlabel
        End Get
        Set(ByVal value As String)
            _searchlabel = value
        End Set
    End Property

    <Category("Colonne")> Public Overrides Property ID() As String
        Get
            Return _ID
        End Get
        Set(ByVal Value As String)
            _ID = Value
        End Set
    End Property

    <Category("Colonne")> Public Property Key() As String
        Get
            Return _key
        End Get
        Set(ByVal Value As String)
            _key = Value
        End Set
    End Property



End Class


'ExpandableObjectConverter: Provides a type converter to convert expandable
'objects. It adds support for properties on an object to the methods and
'properties that TypeConverter provides.
<TypeConverter(GetType(ExpandableObjectConverter))> _
Public Class Sql
    Private strUser As String = ""
    Private strPsw As String = ""
    Private strScript As String = ""



    <DefaultValue(""), NotifyParentProperty(True), RefreshProperties(RefreshProperties.Repaint)> _
    Property [SqlUser]() As String
        Get
            Return strUser
        End Get
        Set(ByVal Value As String)
            strUser = Value
        End Set
    End Property
    <DefaultValue(""), NotifyParentProperty(True), RefreshProperties(RefreshProperties.Repaint), PasswordPropertyText(True)> _
    Property [SqlPsw]() As String
        Get
            Return strPsw
        End Get
        Set(ByVal Value As String)
            strPsw = Value
        End Set
    End Property
    <DefaultValue(""), NotifyParentProperty(True), RefreshProperties(RefreshProperties.Repaint)> _
    Property [SqlScript]() As String
        Get
            Return strScript
        End Get
        Set(ByVal Value As String)
            strScript = Value
        End Set
    End Property
End Class



#End Region

#Region "Collection"

Public Class ColCollection
    'Définition des collections
    Inherits CollectionBase

    Default Public ReadOnly Property Item(ByVal pageIndex As Integer) As FltColumn
        Get
            Return MyBase.List(pageIndex)
        End Get
    End Property

    Public Sub Add(ByVal page As FltColumn)
        MyBase.List.Add(page)
    End Sub

    Public Function IndexOf(ByVal page As FltColumn) As Integer
        Return MyBase.List.IndexOf(page)
    End Function

    Public Function IndexOf(ByVal key As String) As Integer

        Dim myCol As FltColumn
        Dim i As Single = 0

        While (i < MyBase.List.Count)

            myCol = MyBase.List.Item(i)
            If (myCol.Key = key) Then

                Return i

            End If

            i = i + 1

        End While

        Return -1

    End Function
End Class

#End Region

#Region "Designer"

Public Class HQFilterDesigner
    Inherits System.Web.UI.Design.ControlDesigner

    Public Overrides Function getdesignTimeHTML() As String
        Dim writer As New System.IO.StringWriter
        Dim html As New HtmlTextWriter(writer)
        'Dim cmnDir As String
        Dim ctl As HQFilter = CType(Component, HQFilter)


        Dim strTxt As String = "<TD>Controle de filtre"
        Dim intIndex As Integer = 0
        For Each fltc As FltColumn In ctl.FilterColumns
            If fltc.Indexed Then intIndex = intIndex + 1
        Next

        If intIndex > 1 Then
            strTxt = "                              <TD style=""font-weight: bold; color: red"">Il y a plus d'une colonne indexé, aucune données ne sera visible"
        End If


        writer.Write(("<DIV style=""LEFT: " & ctl.Style("LEFT") & "; " & _
                     "TOP: " & ctl.Style("TOP") & "; " & _
                     "POSITION: " & ctl.Style("POSITION") & "; " & _
                     "Z-INDEX: " & ctl.Style("Z-INDEX") & "; " & _
                     "WIDTH: " & ctl.FilterWidth + 10 & "; " & _
                     "HEIGHT: " & ctl.FilterHeight + 30 & """>") & vbCr)

        writer.Write(("<TABLE  id=""Table1"" cellSpacing=""1""") & vbCr)
        writer.Write(("                        cellPadding=""1"" height=""" & _
                      ctl.FilterHeight + 30 & """ width=""" & ctl.FilterWidth + 10 & _
                      """ border=""1"">") & vbCr)
        writer.Write(("                        <TR>") & vbCr)
        writer.Write((strTxt & "</TD>") & vbCr)
        writer.Write(("                        </TR>") & vbCr)
        writer.Write(("                  </TABLE>") & vbCr)
        writer.Write(("</DIV>") & vbCr)


        Return writer.ToString
    End Function
End Class

#End Region



0
Comment
Question by:hqdev
2 Comments
 
LVL 18

Expert Comment

by:DropZone
ID: 19679101
You have the default value as an empty string in the property
Property [SqlConnection]() As Sql

You should remove that attribute (DefaultValue).
0
 

Accepted Solution

by:
hqdev earned 0 total points
ID: 19962347
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question