Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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

share|improve this question

2 Answers 2

<%@ Register TagPrefix="uc1" TagName="BlahBlahBlah" src="~/_controltemplates/MyApp/BlahBlahBlah.ascx" %>

the above should work! unless you dont have that file in 14hive or wrongly named!

Also make sure that your folder in 14 hive is accessible! goto controltemplates folder find MyApp and right click and select "properties", click on security tab and then advanced button. Att the bottom you should see two checkboxes, the first one should be checked, you can also check the other (below "include inheritable permissions from this objects parent") and click ok! now you should inherit the permissions from the parent to the folder and subfolder/files so you can have access to that file ;)

when you click ok, it will uncheck the second checkbox which it should do but it will set the parent access to the children!

share|improve this answer

It was to do with the naming of the ControlTemplates folder. This is created as ControlTemplates. I came across an article on this issue (lost link now). Renaming the folder to _ControlTemplates resolved this issue.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.