So the error that I'm seeing is that PixelTextArea is not a known element. This class is in the APP_Code directory and the control that I'm adding it to is a user control in another directory outside of that.
Any ideas how I fix this?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jerry BlumPosted Oct 1, 2008, 4:02 PM
Nico VanHaasterPosted Oct 1, 2008, 4:02 PM
Yeah i would just create a new custom control and set the inheritance to whatever you like just replace after :
public
partial class newcontrol: System...... whatever you like it to enheritJerry BlumPosted Oct 1, 2008, 3:36 PM
Nico VanHaasterPosted Oct 1, 2008, 1:48 PM
Your register tag is registering a file in the App_code directory which is a cs file, you need to reference the path of the actual ascx file
<%@ Register TagPrefix="customControl" TagName="pixelTextArea" Src="~\App_Code\Common\Controls\PixelTextArea.cs" %>
Like this below
<%@ Register TagPrefix="customControl" TagName="pixelTextArea" Src~\CustomControls\PixelTextArea.ascx" %>
Jerry BlumPosted Oct 1, 2008, 1:45 PM
[code]
<%@ Register TagPrefix="customControl" TagName="pixelTextArea" Src="~\App_Code\Common\Controls\PixelTextArea.cs" %>
[code]
Like I said before this is a class in a .cs file that is inherited from System.Web.UI.HtmlControls.HtmlTextArea and is in App_Code directory. The file that I added the code above to is a user control with an ascx file and .cs file. Is this something that I will need to rebuild a userControl to handle or should I be able to use this as is? Hopefully somebody will be able to help.
Nico VanHaasterPosted Oct 1, 2008, 1:16 PM
Two things here, one it sounds like you your controls in the correct place. The code in the App_Code folder etc. Now have you referenced this control in your web.config or at the top of the page with the <% @Register %> tag?
To use a custom control inside of .Net it needs to know where to find it. This will include the virtual path to the control ie ~/Controls/Customcontrol.asax.
Example http://weblogs.asp.net/scottgu/archive/2006/11/26/tip-trick-how-to-register-user-controls-and-custom-controls-in-web-config.aspx