Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 1.0
This is the forum to discuss the Wrox book Beginning ASP.NET 1.0 with C# by Chris Goode, John Kauffman, Christopher L. Miller, Neil Raybould, S. Srinivasa Sivakumar, Dave Sussman, Ollie Cornes, Rob Birdwell, Matt Butler, Gary Johnson, Ajoy Krishnamoorthy, Juan T. Llibre, Chris Ullman; ISBN: 9780764543708
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 1.0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 21st, 2004, 03:57 AM
Authorized User
 
Join Date: Apr 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default Custom Controls

I'm new to ASP. I'm trying to setup a custom control and am going through the tutorials in the SDK .
Here is the code

Namespace customcontrols
    Public Class clientclickbutton
        Inherits Button
        Protected Overrides Sub addattributestorender(ByVal writer As HtmlTextWriter)
            MyBase.AddAttributesToRender(writer)
            writer.AddAttribute("OnClick", "Alert('Thanks');")
        End Sub
    End Class
End Namespace


<%@ Register TagPrefix="Custom" Namespace="CustomControls.MyControl" Assembly = "CustomControls" %>
<%@ Page Language="vb" AutoEventWireup="false" src="WebForm1.aspx.vb" Inherits="WebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
    <body MS_POSITIONING="GridLayout">
        <form id="Form1" method="post" runat="server">
            This button handles a client-side click event.
            <Custom:ClientClickButton Id="Button" BackColor="Red" runat="server" />
            <br>
            <br>
        </form>
    </body>
</HTML>

After this I get an error "File or assembly name CustomControls, or one of its dependencies, was not found.." with the @Register line highlighted.
I can't imagine this should be all that difficult and I'm probably missing something very basic here.
Anybody have any pointers for me?





 
Old May 21st, 2004, 07:57 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hello,

You have to add the project name to the register statement:

<%@ Register TagPrefix="Custom" Namespace="<project name>.CustomControls" Assembly = "<project name>" %>

If customcontrols is the name of your project, you are also using customcontrols as the namespace, so it would look like CustomControls.Customcontrols.<etc>. Plus, I believe you don't reference the control in the namespace parameter in the Register tag.

Hope that helps,

Brian
 
Old May 23rd, 2004, 11:04 PM
Authorized User
 
Join Date: Apr 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Brian,
Thanks for the help.
Assembly name error is removed. Now it gives error in namespace decalration.
'Type 'Button' is not defined'

here is the code..
Namespace customcontrols
    Public Class clientclickbutton
        Inherits Button
        Protected Overrides Sub addattributestorender(ByVal writer As HtmlTextWriter)
            MyBase.AddAttributesToRender(writer)
            writer.AddAttribute("OnClick", "Alert('Thanks');")
        End Sub
    End Class
End Namespace

Can u pls help me to resolve this error.

Thanks,
Apry






Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom Controls pro-logic C# 2008 aka C# 3.0 1 November 26th, 2008 10:55 AM
Custom Controls kcis8rm ASP.NET 2.0 Basics 2 July 2nd, 2007 04:07 PM
Custom Controls bmains ASP.NET 1.x and 2.0 Application Design 1 April 8th, 2004 05:26 PM
Custom Controls bmains VS.NET 2002/2003 3 February 5th, 2004 09:54 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.