troubleshooting Question

Namespace problem

Avatar of timothyrmyers
timothyrmyers asked on
.NET ProgrammingVisual Basic.NET
6 Comments1 Solution922 ViewsLast Modified:
I get the following error when I insert this line of code:
<%@ Register TagPrefix="custom" Namespace="myControls" %>

I can see the class named DeleteButtonField when I click on "View Classes".  Am I missing a step somewhere?   I'm using Visual Studio 2008.



Warning      1      Namespace or type specified in the Imports 'myControls' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases.      C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\xxxxx\xxxxx\ShowDeleteButtonField.aspx      1      1      xxxxxx

ShowDeleteButtonButtonField.aspx:
<%@ Page Language="VB" %>
<%@ Register TagPrefix="custom" Namespace="myControls" %>
<!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 id="Head1" runat="server">
    <style type="text/css">
        .grid td, .grid th
        {
            padding:5px;
        }
    </style>
    <title>Show DeleteButtonField</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
    <asp:GridView
        id="grdMovies"
        CssClass="grid"
        DataSourceID="srcMovies"
        DataKeyNames="Id"
        AutoGenerateColumns="false"
        Runat="server">
        <Columns>
        <custom:DeleteButtonField
            ConfirmText="Are you sure that you want to delete this record?" />            
        <asp:BoundField
            DataField="Title"
            HeaderText="Movie Title" />
        <asp:BoundField
            DataField="Director"
            HeaderText="Movie Director" />
        </Columns>
    </asp:GridView>    
 
    <asp:SqlDataSource
        id="srcMovies"
        ConnectionString="<%$ ConnectionStrings:Movies %>"
        SelectCommand="SELECT Id, Title, Director FROM Movies"
        DeleteCommand="DELETE Movies WHERE Id=@Id"
        Runat="server" />
    
    </div>
    </form>
</body>
</html>
 
DeleteButtonField.vb:
Imports System
Imports System.Web.UI.WebControls
 
Namespace myControls
    ''' <summary>
    ''' Displays a confirmation before deleting a record
    ''' </summary>
    Public Class DeleteButtonField
        Inherits ButtonField
 
        Private _confirmText As String = "Delete this record?"
 
        Public Property ConfirmText() As String
            Get
                Return _confirmText
            End Get
            Set(ByVal Value As String)
                _confirmText = Value
            End Set
        End Property
 
        Public Sub New()
            Me.CommandName = "Delete"
            Me.Text = "Delete"
        End Sub
 
        Public Overrides Sub InitializeCell(ByVal cell As DataControlFieldCell, ByVal cellType As DataControlCellType, ByVal rowState As DataControlRowState, ByVal rowIndex As Integer)
            MyBase.InitializeCell(cell, cellType, rowState, rowIndex)
            If cellType = DataControlCellType.DataCell Then
                Dim button As WebControl = CType(cell.Controls(0), WebControl)
                button.Attributes("onclick") = String.Format("return confirm('{0}');", _confirmText)
            End If
        End Sub
 
    End Class
End Namespace
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 6 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros