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. HELP! Can't figure out how to add a UserControl to a Page (from the same project)

HELP! Can't figure out how to add a UserControl to a Page (from the same project)

Scheduled Pinned Locked Moved ASP.NET
helptutorialquestion
6 Posts 4 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.
  • S Offline
    S Offline
    swampwiz
    wrote on last edited by
    #1

    I have a Web App project with a few Page items, as well as a UserControl item. I would like to use this UserControl within the Pages, but I can't seem to add it to the Toolbox. When I do a drag-drop, I get a Text element, which is just the filename of the UserControl. Am I going about this the correct way? Should I instead set up the UserControl as totally separate project and somehow reference it to get into the Toolbox?

    C A K 3 Replies Last reply
    0
    • S swampwiz

      I have a Web App project with a few Page items, as well as a UserControl item. I would like to use this UserControl within the Pages, but I can't seem to add it to the Toolbox. When I do a drag-drop, I get a Text element, which is just the filename of the UserControl. Am I going about this the correct way? Should I instead set up the UserControl as totally separate project and somehow reference it to get into the Toolbox?

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      You shouldn't be using the toolbox at all, because it doesn't really generate nice HTML. You should just write the code in your aspx to add it.

      Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

      1 Reply Last reply
      0
      • S swampwiz

        I have a Web App project with a few Page items, as well as a UserControl item. I would like to use this UserControl within the Pages, but I can't seem to add it to the Toolbox. When I do a drag-drop, I get a Text element, which is just the filename of the UserControl. Am I going about this the correct way? Should I instead set up the UserControl as totally separate project and somehow reference it to get into the Toolbox?

        A Offline
        A Offline
        AlexeiXX3
        wrote on last edited by
        #3

        User controls cant be added to the toolbox To use t just drag the user control directl to the page

        Alexei Rodriguez

        1 Reply Last reply
        0
        • S swampwiz

          I have a Web App project with a few Page items, as well as a UserControl item. I would like to use this UserControl within the Pages, but I can't seem to add it to the Toolbox. When I do a drag-drop, I get a Text element, which is just the filename of the UserControl. Am I going about this the correct way? Should I instead set up the UserControl as totally separate project and somehow reference it to get into the Toolbox?

          K Offline
          K Offline
          kstls
          wrote on last edited by
          #4

          As the others have posted, you do not use the toolbox to add your usercontrol. Instead you drag and drop it, but you may need to be in Design view as you otherwise will just get a reference to the file.

          S 1 Reply Last reply
          0
          • K kstls

            As the others have posted, you do not use the toolbox to add your usercontrol. Instead you drag and drop it, but you may need to be in Design view as you otherwise will just get a reference to the file.

            S Offline
            S Offline
            swampwiz
            wrote on last edited by
            #5

            OK, I went ahead and added the UserControl to a Panel in a Page, but the UserControl was rendered as just a general rectangle, in which there was the message "Error Rendering Control - An unhandled exception has occured. The directive is missing the 'tagprefix' attribute." When I attempted to execute the Web App, I got an error, "The directive is missing a 'tagprefix' attribute. So it seems that I need to add this attribute. I have never heard of this attribute before. Shouldn't the IDE add this attribute automatically? Or perhaps this is just a standard Microsoft bug?

            K 1 Reply Last reply
            0
            • S swampwiz

              OK, I went ahead and added the UserControl to a Panel in a Page, but the UserControl was rendered as just a general rectangle, in which there was the message "Error Rendering Control - An unhandled exception has occured. The directive is missing the 'tagprefix' attribute." When I attempted to execute the Web App, I got an error, "The directive is missing a 'tagprefix' attribute. So it seems that I need to add this attribute. I have never heard of this attribute before. Shouldn't the IDE add this attribute automatically? Or perhaps this is just a standard Microsoft bug?

              K Offline
              K Offline
              kstls
              wrote on last edited by
              #6

              Not sure why it didn't add it automaticly. It should do so. The tagprefix it is reffering to, must be something similar to this line

              <%@ Register src="WebUserControl1.ascx" tagname="WebUserControl1" tagprefix="uc1" %>

              which is added at the top outside the tags You can always add this line yourself. Just name the src, tagname and tagprefix accordingly. Hope this helps.

              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