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