I have created a UserControl (Farm) in my SharePoint Project using VS2012 (for SharePoint 2010). I want to embed/host this in an application page.
I have added properties and events to the UserControl, but I cannot access these in code or in the ASPX (intellisense does not pick these up).
I get a warning "Element 'BlahBlahBlah' is not a known element. This can occur if there is a compilation error in the Web site, or the web.config file is missing.
I need to access properties and events from my user control, but I don't know what I am missing. I initially came across this post User Controls question but it did not shed much light on the matter.
I have the following code:
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
namespace MySPProj.ControlTemplates.MyApp
{
public partial class BlahBlahBlah : UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
public string ShowThisPropertyUpPlease
{
get { return ""; }
set { }
}
}
}
And drag the ascx from the ControlTemplates\MyApp which adds the code to the Application Page as follows:
<%@ Register Src="~/XXX/_ControlTemplates/MyApp/BlahBlahBlah.ascx" TagPrefix="uc1" TagName="BlahBlahBlah" %>
<uc1:BlahBlahBlah runat="server" id="BlahBlahBlah" />
I've tried Src="~/XXX/_ControlTemplates/..." and Src="~/_ControlTemplates/..." but it does not make a difference.
The code behind the application page does not recognise any of the properties. VS2012 just thinks that this is a normal UserControl.
I've omitted events for now.
Any thoughts?
Thanks
Andez