Removing Assembly Page Directive Attribute



Hi,

I was trying to create a very basic custom control that simply outputs
a literal string and the and date. After creating the custom control
class, I referenced the custom control in a webpage. When I added the
following an attribute "Assembly" in the page directive which I
assumed would take compile the custom control and make its
functionality available to to the webpage. When I ran the
application, I got an error

"Could not load file or assembly 'CustomControlTest' or one of its
dependencies. The system cannot find the file specified"

Source error:

<%@ Register TagPrefix="CC" Namespace="MyCustomControls"
Assembly="CustomControlTest" %>

When I removed the Assembly attribute from the page directive, the
application worked fine. How does the webpage know where the class to
be compiled is and why does adding the "Assembly" attribute give me an
error. The following is the source code, but I'd be most appreciative
if someone could elaborate on when or when not to use the "Assembly"
attribute when creating controls.

Source code
----------------------------------------------------------------------------------------------------------------------------------------------------------------

Imports Microsoft.VisualBasic
Imports System
Imports System.Web
Imports System.Web.UI

Namespace MyCustomControls
Public Class CustomControl1 : Inherits Control
Protected Overrides Sub Render(ByVal Output As
System.Web.UI.HtmlTextWriter)
Output.Write("This my my custom control! The time is now "
& DateTime.Now.ToString)

End Sub

End Class
End Namespace

The code for the webpage is as follows:
-------------------------------------------------------------------------------------------------------------------------------------------------------

<%@ Register TagPrefix="CC" Namespace="MyCustomControls"
Assembly="CustomControlTest" %>


<html>
<body>
<form method="POST" action="Default.aspx" runat="server">
The custom control produces the following output
<CC:CustomControl1 runat="server" />
</form>
</body>
</html>

-----------------------------------------------------------------------------------------------------------------------------------------------------

.



Relevant Pages

  • Re: Removing Assembly Page Directive Attribute
    ... I was trying to create a very basic custom control that simply outputs ... I referenced the custom control in a webpage. ... The following is the source code, ... Protected Overrides Sub Render(ByVal Output As ...
    (microsoft.public.dotnet.framework.aspnet.buildingcontrols)
  • Re: Custom controls and the GAC
    ... remove your custom control from your webpage. ... in the references, set local copy to false ... drag your custom control to your web page ...
    (microsoft.public.dotnet.framework.aspnet)
  • Custom Control
    ... I have created a custom control button which when clicked displays a ... message in the JavaScript alert dialog. ... This is the class file: ... Protected Overrides Sub AddAttributesToRender(ByVal Output As ...
    (microsoft.public.dotnet.framework.aspnet)
  • C# Equivalent to VBs WithEvents?
    ... Thanks for reviewing my question. ... a custom control and its source code is in VB. ... What is the replacement for WithEvents? ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: C# Equivalent to VBs WithEvents?
    ... > Thanks for reviewing my question. ... > a custom control and its source code is in VB. ... What is the replacement for WithEvents? ...
    (microsoft.public.dotnet.languages.csharp)

Loading