|
-
Aug 17th, 2008, 09:15 AM
#1
Thread Starter
Frenzied Member
[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:
Imports System.Web.UI
Imports System.Collections
Namespace UI.WebControls.AdHocQuery
<ToolboxData("<{0}:AdHocQueryFilter />")> _
Public Class AdHocQueryFilter
Implements IStateManager
Private m_IsTrackingViewState As Boolean
Private m_ViewState As StateBag
<PersistenceMode(PersistenceMode.Attribute)> _
<System.ComponentModel.NotifyParentProperty(True)> _
Public Property DisplayName() As String
Get
Dim value As Object = ViewState("DisplayName")
Return IIf(value IsNot Nothing, value, String.Empty)
End Get
Set(ByVal value As String)
ViewState("DisplayName") = value
End Set
End Property
<PersistenceMode(PersistenceMode.Attribute)> _
<System.ComponentModel.NotifyParentProperty(True)> _
Public Property FieldName() As String
Get
Dim value As Object = ViewState("FieldName")
Return IIf(value IsNot Nothing, value, String.Empty)
End Get
Set(ByVal value As String)
ViewState("FieldName") = value
End Set
End Property
<PersistenceMode(PersistenceMode.Attribute)> _
<System.ComponentModel.NotifyParentProperty(True)> _
Public Property DataType() As System.TypeCode
Get
Dim value As Object = ViewState("DataType")
Return IIf(value IsNot Nothing, value, TypeCode.Empty)
End Get
Set(ByVal value As System.TypeCode)
ViewState("DataType") = value
End Set
End Property
Public Sub SetDirty()
Me.ViewState.SetDirty(True)
End Sub
Protected Overridable ReadOnly Property ViewState() As StateBag
Get
If m_ViewState Is Nothing Then
m_ViewState = New StateBag(False)
If m_IsTrackingViewState Then
DirectCast(m_ViewState, IStateManager).TrackViewState()
End If
End If
Return m_ViewState
End Get
End Property
<System.ComponentModel.Browsable(False)> _
Public ReadOnly Property IsTrackingViewState() As Boolean Implements System.Web.UI.IStateManager.IsTrackingViewState
Get
Return m_IsTrackingViewState
End Get
End Property
Public Sub LoadViewState(ByVal state As Object) Implements System.Web.UI.IStateManager.LoadViewState
If state IsNot Nothing Then
DirectCast(ViewState, IStateManager).LoadViewState(state)
End If
End Sub
Public Function SaveViewState() As Object Implements System.Web.UI.IStateManager.SaveViewState
Dim retval As Object = Nothing
If m_ViewState IsNot Nothing Then
retval = DirectCast(m_ViewState, IStateManager).SaveViewState
End If
Return retval
End Function
Public Sub TrackViewState() Implements System.Web.UI.IStateManager.TrackViewState
m_IsTrackingViewState = True
If m_ViewState IsNot Nothing Then
DirectCast(m_ViewState, IStateManager).TrackViewState()
End If
End Sub
End Class
End Namespace
Last edited by vbdotnetboy; Aug 19th, 2008 at 11:11 AM.
Reason: Reopening
-
Aug 18th, 2008, 11:50 AM
#2
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" %>
-
Aug 18th, 2008, 12:07 PM
#3
Thread Starter
Frenzied Member
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!
-
Aug 18th, 2008, 12:13 PM
#4
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 
-
Aug 18th, 2008, 12:34 PM
#5
Re: [2005] Problem creating web control
 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.
-
Aug 18th, 2008, 12:40 PM
#6
Re: [2005] Problem creating web control
 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 
-
Aug 18th, 2008, 01:17 PM
#7
Thread Starter
Frenzied Member
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.
-
Aug 19th, 2008, 07:48 AM
#8
Thread Starter
Frenzied Member
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:
Imports System Imports System.Web.UI Namespace UI Public Interface IStateManagedItem : Inherits IStateManager Sub SetDirty() End Interface End Namespace
The class that's inherited for a object that is to be stored in the view state
vb Code:
Imports System Imports System.Web.UI Imports System.ComponentModel Imports System.Text Imports System.Collections.Generic Namespace UI Public Class StateManagedItem Implements IStateManagedItem #Region " Members Section " Private m_ViewState As StateBag Private m_IsTrackingViewState As Boolean = False #End Region #Region " Constructor Section " Public Sub New() m_ViewState = New StateBag End Sub #End Region #Region " Properties Section " Protected ReadOnly Property ViewState() As StateBag Get Return m_ViewState End Get End Property #End Region #Region " Method Section " Public Sub SetDirty() Implements IStateManagedItem.SetDirty m_ViewState.SetDirty(True) End Sub #End Region #Region " IStateManager Members " <Browsable(False)> _ Public ReadOnly Property IsTrackingViewState() As Boolean Implements System.Web.UI.IStateManager.IsTrackingViewState Get Return m_IsTrackingViewState End Get End Property Public Sub LoadViewState(ByVal state As Object) Implements System.Web.UI.IStateManager.LoadViewState DirectCast(Me.ViewState, IStateManager).LoadViewState(state) End Sub Public Function SaveViewState() As Object Implements System.Web.UI.IStateManager.SaveViewState Return DirectCast(Me.ViewState, IStateManager).SaveViewState End Function Public Sub TrackViewState() Implements System.Web.UI.IStateManager.TrackViewState m_IsTrackingViewState = True DirectCast(Me.ViewState, IStateManager).TrackViewState() End Sub #End Region End Class End Namespace
The collection to hold the state managed objects
vb Code:
Imports System Imports System.Collections Imports System.Collections.Specialized Imports System.Security.Permissions Imports System.Collections.Generic Imports System.Web Imports System.Web.UI Namespace UI Public Class StateManagedCollection(Of T As {Class, IStateManagedItem, New}) Implements Collections.Generic.ICollection(Of T) Implements IStateManager Private m_Tracking As Boolean = False Private m_Items As New Collections.Generic.List(Of T) #Region " IStateManager Members Section " Public ReadOnly Property IsTrackingViewState() As Boolean Implements System.Web.UI.IStateManager.IsTrackingViewState Get Return m_Tracking End Get End Property Public Sub LoadViewState(ByVal state As Object) Implements System.Web.UI.IStateManager.LoadViewState If state IsNot Nothing Then Dim p As Pair = state If p IsNot Nothing Then Dim count As Integer = Convert.ToInt32(p.First) Dim savedItems As Object() = DirectCast(p.Second, Object()) For Each savedState As Object In savedItems Dim item As New T item.TrackViewState() item.LoadViewState(savedState) m_Items.Add(item) Next End If End If End Sub Public Function SaveViewState() As Object Implements System.Web.UI.IStateManager.SaveViewState Dim saveList As Object() = New Object(m_Items.Count) {} For i As Integer = 0 To m_Items.Count - 1 Dim item As T = m_Items(i) SetItemDirty(item) saveList(i) = item.SaveViewState Next Return New Pair(m_Items.Count, saveList) End Function Public Sub TrackViewState() Implements System.Web.UI.IStateManager.TrackViewState m_Tracking = True For Each item As IStateManager In m_Items item.TrackViewState() Next End Sub Protected Overridable Sub SetItemDirty(ByVal item As T) item.SetDirty() End Sub #End Region Public Sub Add(ByVal item As T) Implements System.Collections.Generic.ICollection(Of T).Add m_Items.Add(item) End Sub Public Sub Clear() Implements System.Collections.Generic.ICollection(Of T).Clear m_Items.Clear() End Sub Public Function Contains(ByVal item As T) As Boolean Implements System.Collections.Generic.ICollection(Of T).Contains Return m_Items.Contains(item) End Function Public Sub CopyTo(ByVal array() As T, ByVal arrayIndex As Integer) Implements System.Collections.Generic.ICollection(Of T).CopyTo m_Items.CopyTo(array, arrayIndex) End Sub Public ReadOnly Property Count() As Integer Implements System.Collections.Generic.ICollection(Of T).Count Get Return m_Items.Count End Get End Property Public ReadOnly Property IsReadOnly() As Boolean Implements System.Collections.Generic.ICollection(Of T).IsReadOnly Get Return False End Get End Property Public Function Remove(ByVal item As T) As Boolean Implements System.Collections.Generic.ICollection(Of T).Remove Return m_Items.Remove(item) End Function Public Function GetEnumerator() As System.Collections.Generic.IEnumerator(Of T) Implements System.Collections.Generic.IEnumerable(Of T).GetEnumerator Return m_Items.GetEnumerator End Function Protected Function GetEnumerator1() As System.Collections.IEnumerator Implements System.Collections.IEnumerable.GetEnumerator Return CType(m_Items, IEnumerable).GetEnumerator End Function End Class End Namespace
The object that's part of a list within the control itself
vb Code:
Imports System.Web.UI Imports System.Collections Namespace UI.WebControls <ToolboxData("<{0}:AdHocQueryFilter></{0}:AdHocQueryFilter>")> _ Public Class AdHocQueryFilter : Inherits StateManagedItem <PersistenceMode(PersistenceMode.Attribute)> _ <System.ComponentModel.NotifyParentProperty(True)> _ Public Property DisplayName() As String Get Dim value As Object = ViewState("DisplayName") Return IIf(value IsNot Nothing, value, String.Empty) End Get Set(ByVal value As String) ViewState("DisplayName") = value End Set End Property <PersistenceMode(PersistenceMode.Attribute)> _ <System.ComponentModel.NotifyParentProperty(True)> _ Public Property FieldName() As String Get Dim value As Object = ViewState("FieldName") Return IIf(value IsNot Nothing, value, String.Empty) End Get Set(ByVal value As String) ViewState("FieldName") = value End Set End Property <PersistenceMode(PersistenceMode.Attribute)> _ <System.ComponentModel.NotifyParentProperty(True)> _ Public Property DataType() As System.TypeCode Get Dim value As Object = ViewState("DataType") Return IIf(value IsNot Nothing, value, TypeCode.Empty) End Get Set(ByVal value As System.TypeCode) ViewState("DataType") = value End Set End Property End Class End Namespace
This is just the bits and pieces of the control itself
vb Code:
Private m_Filters As StateManagedCollection(Of AdHocQueryFilter) = Nothing <MergableProperty(True)> _ <PersistenceMode(PersistenceMode.InnerProperty)> _ Public ReadOnly Property Filters() As StateManagedCollection(Of AdHocQueryFilter) Get If m_Filters Is Nothing Then m_Filters = New StateManagedCollection(Of AdHocQueryFilter) If MyBase.IsTrackingViewState Then m_Filters.TrackViewState() End If End If Return m_Filters End Get 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>
</div>
</form>
</body>
</html>
-
Aug 19th, 2008, 03:47 PM
#9
Lively Member
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
-
Aug 20th, 2008, 07:42 AM
#10
Thread Starter
Frenzied Member
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|