0

I'm create default webpart and creat default user control, drug and drop control to designer on web part and it generate code:

<%@ Register  Src="~/_controltemplates/15/InfoTable-SP2013WebPart/UserControl1.ascx" TagPrefix="uc1" TagName="UserControl1" %>
...
<uc1:UserControl1 runat="server" id="UserControl1"></uc1:UserControl1>

But i have warning - "UserControl not know element" and IDE can't generate InitializeControl()

If i change it to:

<%@ Register Namespace="InfoTable_SP2013WebPart.ControlTemplates.InfoTable_SP2013WebPart.UserControl1" 
    Assembly="$SharePoint.Project.AssemblyFullName$"
    Src="~/_controltemplates/15/InfoTable-SP2013WebPart/UserControl1.ascx" TagPrefix="uc1" TagName="UserControl1" %>

<uc1:UserControl1 runat="server" id="UserControl1"></uc1:UserControl1>

Compiler say

"Unrecognized tag prefix 'uc1'"

What i should do right?

  • are you adding user control to master page ? – Nikhil J Aug 22 '14 at 14:05
  • No. Place UC to webpart – Actimele Aug 24 '14 at 21:45
1

i dont get what your tryinh todo? the first method is correct the second you cant add namespace and assembly.

aspx:

<%@ Register  Src="~/_controltemplates/15/InfoTable-SP2013WebPart/UserControl1.ascx" TagPrefix="uc1" TagName="UserControl1" %>
...
<uc1:UserControl1 runat="server" id="UserControl1"></uc1:UserControl1>

so the issue lies within the control, you dragged and droped from the toolbox? make sure that the version you have within the toolbox is the same version your referencing within the url on 15 hive! The above should work just fine!

else a work around...

within your project rather than drag drop that control... goto solution explorer and create a mapped folder to controltemplates folder and add that user control within that mapped folder from that same folder (copy the user control ascx from controltemplates and past it into your project within the mapped folder) now drag and drop the user control from the mapped folder into the aspx file and see if it works that way.

  • dug and drop from solution explorer from mapped controltemplates folder, not from toolbox. Versions should be the same because i create it in one time. – Actimele Aug 24 '14 at 21:51
0

Register the user control using the following code:

<%@ Register
Assembly="BBB.XXX.Webparts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b86a9e59abbaa56b"
Namespace="BBB.XXX.Webparts.ControlTemplates.BBB.XXX.Webparts"
TagPrefix="uc1" %>

You can get the assembly from web.config

<uc1:WorkflowComments ID="WorkflowComments1" runat="server" />

Important: remove the TagName!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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