Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Two Issues with Custom Control with ASP.NET Site

Two Issues with Custom Control with ASP.NET Site

Scheduled Pinned Locked Moved ASP.NET
asp-nethelpcsharphtmldotnet
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Dominick Marciano
    wrote on last edited by
    #1

    Good Afternoon, I am working on a project where I will need a custom control added to a site. Since I have never worked with them previously, I decided to try and make a very basic control and a test site so I can learn how to do everything properly. For instructions, I was using the steps outlined on Microsoft's website here. Therefore I created a solution with two projects - Custom Control Assembly and Custom Control Test Site, both of which are using the 4.7 version of the .NET Framework. For the Custom Control Assembly, the Assembly name is CustomControlAssembly and the Default namespace is CustomControlNamepsace. There is one file in the project called CustomControl which inherits from

    System.Web.UI.Control

    . This project built without any errors and I copied the CustomControlAssembly.dll to the /Custom Control Test/Custom Control Test Site/bin folder as instructed on the Microsoft page listed above. The Custom Control Test Site is a web forms site. On the Default.aspx page I added the following directive right underneath the

    <%@ Page %>

    directive:

    <%@ Register TagPrefix="Custom" Namespace="CustomControlNamespace" Assembly="CustomControlAssembly" %>

    In the page, I am able to add the following tag and IntelliSense correctly finds it:

    However, if I try to add an ID properties (in order to name it like I do with all ASP.NET controls), like the following:

    I get the following error message: CS0400 - The type or namespace name 'CustomControlNamespace' could not be found in the global namespace (are you missing an assembly reference?) If I take the ID="CustomControl1" out of the tag, then the site will build fine again. However, when I run the site, the custom control does not show anything on the site. I tried updating the CustomControl to inherit from

    System.Web.UI.UserControl

    instead of

    System.Web.UI.Control

    but it still doesn't display on the Default.aspx page. The following is the markup of the CustomControl.ascx file:

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups