Results 1 to 10 of 10

Thread: [2005] Problem creating web control

  1. #1

    Thread Starter
    Frenzied Member vbdotnetboy's Avatar
    Join Date
    Jun 2004
    Location
    Lewisburg, PA "Next year Raiders in the Super Bowl"
    Posts
    1,310

    Angry [2005] Problem creating web control

    ok here's what i'm trying to do

    here's my control that i'm trying to make, i want the filters to work along the lines of how the SelectParameters do in the SqlDataSource. the problem is the designer keeps telling me that the cssi:AdHocQueryFilter is an unknown server tag.
    HTML Code:
    <cssi:AdHocQueryBuilder ID="AdHocQueryBuilder1" runat="server">
                    <Filters>
                        <cssi:AdHocQueryFilter DataType="dateTime" FieldName="dd" DisplayName="dfs" />
                    </Filters>
                </cssi:AdHocQueryBuilder>
                
                <asp:SqlDataSource ID="SqlDataSource1" runat="server">
                    <SelectParameters>
                        <asp:Parameter Name="xxx" DefaultValue="ddd" />
                    </SelectParameters>
                </asp:SqlDataSource>
    here's the code for the AdHocQueryFilter class

    vb Code:
    1. Imports System.Web.UI
    2. Imports System.Collections
    3. Namespace UI.WebControls.AdHocQuery
    4.  
    5.     <ToolboxData("<{0}:AdHocQueryFilter />")> _
    6.     Public Class AdHocQueryFilter
    7.         Implements IStateManager
    8.  
    9.         Private m_IsTrackingViewState As Boolean
    10.         Private m_ViewState As StateBag
    11.  
    12.         <PersistenceMode(PersistenceMode.Attribute)> _
    13.         <System.ComponentModel.NotifyParentProperty(True)> _
    14.         Public Property DisplayName() As String
    15.             Get
    16.                 Dim value As Object = ViewState("DisplayName")
    17.                 Return IIf(value IsNot Nothing, value, String.Empty)
    18.             End Get
    19.             Set(ByVal value As String)
    20.                 ViewState("DisplayName") = value
    21.             End Set
    22.         End Property
    23.  
    24.         <PersistenceMode(PersistenceMode.Attribute)> _
    25.         <System.ComponentModel.NotifyParentProperty(True)> _
    26.         Public Property FieldName() As String
    27.             Get
    28.                 Dim value As Object = ViewState("FieldName")
    29.                 Return IIf(value IsNot Nothing, value, String.Empty)
    30.             End Get
    31.             Set(ByVal value As String)
    32.                 ViewState("FieldName") = value
    33.             End Set
    34.         End Property
    35.  
    36.         <PersistenceMode(PersistenceMode.Attribute)> _
    37.         <System.ComponentModel.NotifyParentProperty(True)> _
    38.         Public Property DataType() As System.TypeCode
    39.             Get
    40.                 Dim value As Object = ViewState("DataType")
    41.                 Return IIf(value IsNot Nothing, value, TypeCode.Empty)
    42.             End Get
    43.             Set(ByVal value As System.TypeCode)
    44.                 ViewState("DataType") = value
    45.             End Set
    46.         End Property
    47.  
    48.         Public Sub SetDirty()
    49.             Me.ViewState.SetDirty(True)
    50.         End Sub
    51.  
    52.         Protected Overridable ReadOnly Property ViewState() As StateBag
    53.             Get
    54.                 If m_ViewState Is Nothing Then
    55.                     m_ViewState = New StateBag(False)
    56.                     If m_IsTrackingViewState Then
    57.                         DirectCast(m_ViewState, IStateManager).TrackViewState()
    58.                     End If
    59.                 End If
    60.                 Return m_ViewState
    61.             End Get
    62.         End Property
    63.  
    64.         <System.ComponentModel.Browsable(False)> _
    65.         Public ReadOnly Property IsTrackingViewState() As Boolean Implements System.Web.UI.IStateManager.IsTrackingViewState
    66.             Get
    67.                 Return m_IsTrackingViewState
    68.             End Get
    69.         End Property
    70.  
    71.         Public Sub LoadViewState(ByVal state As Object) Implements System.Web.UI.IStateManager.LoadViewState
    72.             If state IsNot Nothing Then
    73.                 DirectCast(ViewState, IStateManager).LoadViewState(state)
    74.             End If
    75.         End Sub
    76.  
    77.         Public Function SaveViewState() As Object Implements System.Web.UI.IStateManager.SaveViewState
    78.             Dim retval As Object = Nothing
    79.             If m_ViewState IsNot Nothing Then
    80.                 retval = DirectCast(m_ViewState, IStateManager).SaveViewState
    81.             End If
    82.             Return retval
    83.         End Function
    84.  
    85.         Public Sub TrackViewState() Implements System.Web.UI.IStateManager.TrackViewState
    86.             m_IsTrackingViewState = True
    87.             If m_ViewState IsNot Nothing Then
    88.                 DirectCast(m_ViewState, IStateManager).TrackViewState()
    89.             End If
    90.         End Sub
    91.  
    92.     End Class
    93.  
    94. End Namespace
    Last edited by vbdotnetboy; Aug 19th, 2008 at 11:11 AM. Reason: Reopening

    Derek - Using VS 2008 99% of the time and VS 2003 1% of the time

    Please Help Us To Save Ana

    ● Helpful Links: DNR TV | Awesome site for tips | Using ADO.NET to work with Excel | Xml Namespace 2.0 Framework Changes|Ultra High Security Password Generator | Mendhak's ADO.NET Tutorial
    ● Code Bank: Random Password Generator | Generic DbProviderFactory Access
    ● Site Work: Bottle Run Xtreme | Spaids Racing.com

    Company I work for - CSSI

    WHEN POSTING PLEASE INDICATE VERSION

    Please use vbcode tags or code tags when posting code
    [highlight=vb]ALL your code goes here[/highlight] or [code]ALL your code goes here[/code]

    If my post helped you in anyway... please be kind and give me some ratings

  2. #2
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: [2005] Problem creating web control

    I assume this error is happening on the page itself? If so, did you add a reference to the cssi prefix on the page?
    Code:
    <%@ Register Assembly="MyAssembly" Namespace="MyNamespace" TagPrefix="cssi" %>
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  3. #3

    Thread Starter
    Frenzied Member vbdotnetboy's Avatar
    Join Date
    Jun 2004
    Location
    Lewisburg, PA "Next year Raiders in the Super Bowl"
    Posts
    1,310

    Re: [2005] Problem creating web control

    No, i have that, but with you asking about that, i think i found my problem. The AdHocQueryFilter class resides in namespace UI.WebControls.AdHocQuery, as where the AdHocQueryBuilder control resides in the UI.WebControls namespace and I have this at the top

    HTML Code:
    <%@ Register Assembly="CSSI.Web" Namespace="CSSI.Web.UI.WebControls" TagPrefix="cssi" %>
    Which makes perfect sense now why I'm getting the error!

    Derek - Using VS 2008 99% of the time and VS 2003 1% of the time

    Please Help Us To Save Ana

    ● Helpful Links: DNR TV | Awesome site for tips | Using ADO.NET to work with Excel | Xml Namespace 2.0 Framework Changes|Ultra High Security Password Generator | Mendhak's ADO.NET Tutorial
    ● Code Bank: Random Password Generator | Generic DbProviderFactory Access
    ● Site Work: Bottle Run Xtreme | Spaids Racing.com

    Company I work for - CSSI

    WHEN POSTING PLEASE INDICATE VERSION

    Please use vbcode tags or code tags when posting code
    [highlight=vb]ALL your code goes here[/highlight] or [code]ALL your code goes here[/code]

    If my post helped you in anyway... please be kind and give me some ratings

  4. #4
    Frenzied Member
    Join Date
    Jan 2006
    Posts
    1,875

    Re: [2005] Problem creating web control

    not sure if changing TagPrefix = "cssi" to TagPrefix = "cc1" or "uc1" will do the trick.
    __________________
    Rate the posts that helped you

  5. #5
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: [2005] Problem creating web control

    Quote Originally Posted by riteshjain1982
    not sure if changing TagPrefix = "cssi" to TagPrefix = "cc1" or "uc1" will do the trick.
    The prefix tags can be anything (even something else other than what's specified in a control's assembly if it's in a seperate DLL). cc1 is just short for CustomControl1 or UserControl1.
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  6. #6
    Frenzied Member
    Join Date
    Jan 2006
    Posts
    1,875

    Re: [2005] Problem creating web control

    Quote Originally Posted by kasracer
    The prefix tags can be anything (even something else other than what's specified in a control's assembly if it's in a seperate DLL). cc1 is just short for CustomControl1 or UserControl1.
    thanks for info
    __________________
    Rate the posts that helped you

  7. #7

    Thread Starter
    Frenzied Member vbdotnetboy's Avatar
    Join Date
    Jun 2004
    Location
    Lewisburg, PA "Next year Raiders in the Super Bowl"
    Posts
    1,310

    Re: [2005] Problem creating web control

    no, it's because of the namespace's the actual control is in the CSSI.Web.UI.WebControls namespace, which is referenced, while the filter class is in CSSI.Web.UI.WebControls.AdHocQuery namespace.

    Derek - Using VS 2008 99% of the time and VS 2003 1% of the time

    Please Help Us To Save Ana

    ● Helpful Links: DNR TV | Awesome site for tips | Using ADO.NET to work with Excel | Xml Namespace 2.0 Framework Changes|Ultra High Security Password Generator | Mendhak's ADO.NET Tutorial
    ● Code Bank: Random Password Generator | Generic DbProviderFactory Access
    ● Site Work: Bottle Run Xtreme | Spaids Racing.com

    Company I work for - CSSI

    WHEN POSTING PLEASE INDICATE VERSION

    Please use vbcode tags or code tags when posting code
    [highlight=vb]ALL your code goes here[/highlight] or [code]ALL your code goes here[/code]

    If my post helped you in anyway... please be kind and give me some ratings

  8. #8

    Thread Starter
    Frenzied Member vbdotnetboy's Avatar
    Join Date
    Jun 2004
    Location
    Lewisburg, PA "Next year Raiders in the Super Bowl"
    Posts
    1,310

    Re: [2005] Problem creating web control

    ok i've reopened this thread because this still doesn't work and I can't figure out for the life of me why. Please i'm begging for someone to help me figure this out. i've followed difference suggestions and nothing works.

    here's me code

    My interface to be implemented for any and all objects that will use the IStateManager
    vb Code:
    1. Imports System
    2. Imports System.Web.UI
    3. Namespace UI
    4.  
    5.     Public Interface IStateManagedItem : Inherits IStateManager
    6.  
    7.         Sub SetDirty()
    8.  
    9.     End Interface
    10.  
    11. End Namespace

    The class that's inherited for a object that is to be stored in the view state
    vb Code:
    1. Imports System
    2. Imports System.Web.UI
    3. Imports System.ComponentModel
    4. Imports System.Text
    5. Imports System.Collections.Generic
    6. Namespace UI
    7.  
    8.     Public Class StateManagedItem
    9.         Implements IStateManagedItem
    10.  
    11. #Region " Members Section "
    12.  
    13.         Private m_ViewState As StateBag
    14.         Private m_IsTrackingViewState As Boolean = False
    15.  
    16. #End Region
    17.  
    18. #Region " Constructor Section "
    19.  
    20.         Public Sub New()
    21.             m_ViewState = New StateBag
    22.         End Sub
    23.  
    24. #End Region
    25.  
    26. #Region " Properties Section "
    27.  
    28.         Protected ReadOnly Property ViewState() As StateBag
    29.             Get
    30.                 Return m_ViewState
    31.             End Get
    32.         End Property
    33.  
    34. #End Region
    35.  
    36. #Region " Method Section "
    37.  
    38.         Public Sub SetDirty() Implements IStateManagedItem.SetDirty
    39.             m_ViewState.SetDirty(True)
    40.         End Sub
    41.  
    42. #End Region
    43.  
    44. #Region " IStateManager Members "
    45.  
    46.         <Browsable(False)> _
    47.         Public ReadOnly Property IsTrackingViewState() As Boolean Implements System.Web.UI.IStateManager.IsTrackingViewState
    48.             Get
    49.                 Return m_IsTrackingViewState
    50.             End Get
    51.         End Property
    52.  
    53.         Public Sub LoadViewState(ByVal state As Object) Implements System.Web.UI.IStateManager.LoadViewState
    54.             DirectCast(Me.ViewState, IStateManager).LoadViewState(state)
    55.         End Sub
    56.  
    57.         Public Function SaveViewState() As Object Implements System.Web.UI.IStateManager.SaveViewState
    58.             Return DirectCast(Me.ViewState, IStateManager).SaveViewState
    59.         End Function
    60.  
    61.         Public Sub TrackViewState() Implements System.Web.UI.IStateManager.TrackViewState
    62.             m_IsTrackingViewState = True
    63.             DirectCast(Me.ViewState, IStateManager).TrackViewState()
    64.         End Sub
    65.  
    66. #End Region
    67.  
    68.     End Class
    69.  
    70. End Namespace


    The collection to hold the state managed objects
    vb Code:
    1. Imports System
    2. Imports System.Collections
    3. Imports System.Collections.Specialized
    4. Imports System.Security.Permissions
    5. Imports System.Collections.Generic
    6. Imports System.Web
    7. Imports System.Web.UI
    8. Namespace UI
    9.  
    10.     Public Class StateManagedCollection(Of T As {Class, IStateManagedItem, New})
    11.         Implements Collections.Generic.ICollection(Of T)
    12.         Implements IStateManager
    13.  
    14.         Private m_Tracking As Boolean = False
    15.         Private m_Items As New Collections.Generic.List(Of T)
    16.  
    17. #Region " IStateManager Members Section "
    18.  
    19.         Public ReadOnly Property IsTrackingViewState() As Boolean Implements System.Web.UI.IStateManager.IsTrackingViewState
    20.             Get
    21.                 Return m_Tracking
    22.             End Get
    23.         End Property
    24.  
    25.         Public Sub LoadViewState(ByVal state As Object) Implements System.Web.UI.IStateManager.LoadViewState
    26.             If state IsNot Nothing Then
    27.                 Dim p As Pair = state
    28.                 If p IsNot Nothing Then
    29.                     Dim count As Integer = Convert.ToInt32(p.First)
    30.                     Dim savedItems As Object() = DirectCast(p.Second, Object())
    31.                     For Each savedState As Object In savedItems
    32.                         Dim item As New T
    33.                         item.TrackViewState()
    34.                         item.LoadViewState(savedState)
    35.                         m_Items.Add(item)
    36.                     Next
    37.                 End If
    38.             End If
    39.         End Sub
    40.  
    41.         Public Function SaveViewState() As Object Implements System.Web.UI.IStateManager.SaveViewState
    42.             Dim saveList As Object() = New Object(m_Items.Count) {}
    43.             For i As Integer = 0 To m_Items.Count - 1
    44.                 Dim item As T = m_Items(i)
    45.                 SetItemDirty(item)
    46.                 saveList(i) = item.SaveViewState
    47.             Next
    48.             Return New Pair(m_Items.Count, saveList)
    49.         End Function
    50.  
    51.         Public Sub TrackViewState() Implements System.Web.UI.IStateManager.TrackViewState
    52.             m_Tracking = True
    53.             For Each item As IStateManager In m_Items
    54.                 item.TrackViewState()
    55.             Next
    56.         End Sub
    57.  
    58.         Protected Overridable Sub SetItemDirty(ByVal item As T)
    59.             item.SetDirty()
    60.         End Sub
    61.  
    62. #End Region
    63.  
    64.         Public Sub Add(ByVal item As T) Implements System.Collections.Generic.ICollection(Of T).Add
    65.             m_Items.Add(item)
    66.         End Sub
    67.  
    68.         Public Sub Clear() Implements System.Collections.Generic.ICollection(Of T).Clear
    69.             m_Items.Clear()
    70.         End Sub
    71.  
    72.         Public Function Contains(ByVal item As T) As Boolean Implements System.Collections.Generic.ICollection(Of T).Contains
    73.             Return m_Items.Contains(item)
    74.         End Function
    75.  
    76.         Public Sub CopyTo(ByVal array() As T, ByVal arrayIndex As Integer) Implements System.Collections.Generic.ICollection(Of T).CopyTo
    77.             m_Items.CopyTo(array, arrayIndex)
    78.         End Sub
    79.  
    80.         Public ReadOnly Property Count() As Integer Implements System.Collections.Generic.ICollection(Of T).Count
    81.             Get
    82.                 Return m_Items.Count
    83.             End Get
    84.         End Property
    85.  
    86.         Public ReadOnly Property IsReadOnly() As Boolean Implements System.Collections.Generic.ICollection(Of T).IsReadOnly
    87.             Get
    88.                 Return False
    89.             End Get
    90.         End Property
    91.  
    92.         Public Function Remove(ByVal item As T) As Boolean Implements System.Collections.Generic.ICollection(Of T).Remove
    93.             Return m_Items.Remove(item)
    94.         End Function
    95.  
    96.         Public Function GetEnumerator() As System.Collections.Generic.IEnumerator(Of T) Implements System.Collections.Generic.IEnumerable(Of T).GetEnumerator
    97.             Return m_Items.GetEnumerator
    98.         End Function
    99.  
    100.         Protected Function GetEnumerator1() As System.Collections.IEnumerator Implements System.Collections.IEnumerable.GetEnumerator
    101.             Return CType(m_Items, IEnumerable).GetEnumerator
    102.         End Function
    103.  
    104.     End Class
    105.  
    106. End Namespace


    The object that's part of a list within the control itself
    vb Code:
    1. Imports System.Web.UI
    2. Imports System.Collections
    3. Namespace UI.WebControls
    4.  
    5.     <ToolboxData("<{0}:AdHocQueryFilter></{0}:AdHocQueryFilter>")> _
    6.     Public Class AdHocQueryFilter : Inherits StateManagedItem
    7.  
    8.         <PersistenceMode(PersistenceMode.Attribute)> _
    9.         <System.ComponentModel.NotifyParentProperty(True)> _
    10.         Public Property DisplayName() As String
    11.             Get
    12.                 Dim value As Object = ViewState("DisplayName")
    13.                 Return IIf(value IsNot Nothing, value, String.Empty)
    14.             End Get
    15.             Set(ByVal value As String)
    16.                 ViewState("DisplayName") = value
    17.             End Set
    18.         End Property
    19.  
    20.         <PersistenceMode(PersistenceMode.Attribute)> _
    21.         <System.ComponentModel.NotifyParentProperty(True)> _
    22.         Public Property FieldName() As String
    23.             Get
    24.                 Dim value As Object = ViewState("FieldName")
    25.                 Return IIf(value IsNot Nothing, value, String.Empty)
    26.             End Get
    27.             Set(ByVal value As String)
    28.                 ViewState("FieldName") = value
    29.             End Set
    30.         End Property
    31.  
    32.         <PersistenceMode(PersistenceMode.Attribute)> _
    33.         <System.ComponentModel.NotifyParentProperty(True)> _
    34.         Public Property DataType() As System.TypeCode
    35.             Get
    36.                 Dim value As Object = ViewState("DataType")
    37.                 Return IIf(value IsNot Nothing, value, TypeCode.Empty)
    38.             End Get
    39.             Set(ByVal value As System.TypeCode)
    40.                 ViewState("DataType") = value
    41.             End Set
    42.         End Property
    43.  
    44.     End Class
    45.  
    46. End Namespace


    This is just the bits and pieces of the control itself
    vb Code:
    1. Private m_Filters As StateManagedCollection(Of AdHocQueryFilter) = Nothing
    2.  
    3.         <MergableProperty(True)> _
    4.         <PersistenceMode(PersistenceMode.InnerProperty)> _
    5.         Public ReadOnly Property Filters() As StateManagedCollection(Of AdHocQueryFilter)
    6.             Get
    7.                 If m_Filters Is Nothing Then
    8.                     m_Filters = New StateManagedCollection(Of AdHocQueryFilter)
    9.                     If MyBase.IsTrackingViewState Then
    10.                         m_Filters.TrackViewState()
    11.                     End If
    12.                 End If
    13.                 Return m_Filters
    14.             End Get
    15.         End Property


    Finally this is what it does
    HTML Code:
    <%@ Page Language="VB" AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="_Default" %>
    
    <%@ Register Assembly="CSSI.Web" Namespace="CSSI.Web.UI.WebControls" TagPrefix="cssi" %>
    
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
            <asp:ScriptManager ID="ScriptManager1" runat="server" />
            <div>
                <cssi:adhocquerybuilder id="AdHocQueryBuilder1" runat="server">
                    <Filters /> <!--NOTICE THIS RIGHT HERE WHY!!!!-->
                </cssi:adhocquerybuilder>
                &nbsp;</div>
        </form>
    </body>
    </html>

    Derek - Using VS 2008 99% of the time and VS 2003 1% of the time

    Please Help Us To Save Ana

    ● Helpful Links: DNR TV | Awesome site for tips | Using ADO.NET to work with Excel | Xml Namespace 2.0 Framework Changes|Ultra High Security Password Generator | Mendhak's ADO.NET Tutorial
    ● Code Bank: Random Password Generator | Generic DbProviderFactory Access
    ● Site Work: Bottle Run Xtreme | Spaids Racing.com

    Company I work for - CSSI

    WHEN POSTING PLEASE INDICATE VERSION

    Please use vbcode tags or code tags when posting code
    [highlight=vb]ALL your code goes here[/highlight] or [code]ALL your code goes here[/code]

    If my post helped you in anyway... please be kind and give me some ratings

  9. #9
    Lively Member
    Join Date
    Aug 2008
    Location
    North Carolina
    Posts
    114

    Re: [2005] Problem creating web control

    I had a similar problem with WUC's that worked before then suddenly didn't.

    See below for what I did to resolve my issue. Hope it helps.

    http://www.vbforums.com/showthread.php?t=536406

    Regards,
    kul2bme

  10. #10

    Thread Starter
    Frenzied Member vbdotnetboy's Avatar
    Join Date
    Jun 2004
    Location
    Lewisburg, PA "Next year Raiders in the Super Bowl"
    Posts
    1,310

    Re: [2005] Problem creating web control

    thanks but that didn't do it either. this is what shows up in the designer when i place anything whether it be a style the or the filters.


    Derek - Using VS 2008 99% of the time and VS 2003 1% of the time

    Please Help Us To Save Ana

    ● Helpful Links: DNR TV | Awesome site for tips | Using ADO.NET to work with Excel | Xml Namespace 2.0 Framework Changes|Ultra High Security Password Generator | Mendhak's ADO.NET Tutorial
    ● Code Bank: Random Password Generator | Generic DbProviderFactory Access
    ● Site Work: Bottle Run Xtreme | Spaids Racing.com

    Company I work for - CSSI

    WHEN POSTING PLEASE INDICATE VERSION

    Please use vbcode tags or code tags when posting code
    [highlight=vb]ALL your code goes here[/highlight] or [code]ALL your code goes here[/code]

    If my post helped you in anyway... please be kind and give me some ratings

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width