MarkVF
MarkVF

Reputation: 23

User Controls not working in Visual Studio 2015

A user control that was working is no longer being picked up in the ASPX file.

ASPX File

<%@ Register TagPrefix="Uc1" TagName="ContactForm" Src="~/Controls/VFEmailForm.ascx"  %>

<uc1:VFEmailForm ID="VFEmailForm" runat="server" />

It was working but now isn't. A green line appears under the uc1:VFEmailForm and when you type Uc intellisense doesn't show Uc1. It is as though the register statement does not work - well it obviously doesn't. This was all working prior to upgrading to Visual Studio 2015.

I've shown part of my web.config file as ancient posts have suggested this may be the cause.

Web.config

<pages>
  <namespaces>
    <add namespace="System.Web.Optimization" />
  </namespaces>
  <controls>
    <add tagPrefix="webopt" assembly="Microsoft.AspNet.Web.Optimization.WebForms" namespace="Microsoft.AspNet.Web.Optimization.WebForms" />
    <add tagPrefix="ajaxToolkit" assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" />
  </controls>
</pages>

If there is a guru out there who can fix this I would appreciate it.

Upvotes: 0

Views: 2444

Answers (3)

student
student

Reputation: 1

I use Visual studio 2017, and faced a similar problem: Having green, wavy lines under the tagName instead the whole line, i.e., <Uc1:***ContactForm*** ...>. As part of this, I was getting this error:

Element ContactForm is not a known element.

A solution posted by @mitoutsnd on ASP.NET solved the problem by suggesting that I use:

Build > Rebuild Solution

This solved my problem.

Upvotes: 0

InteXX
InteXX

Reputation: 6367

I had the same problem when building under x64. I switched to x86, rebuilt the project and VS 2015 worked as expected.

Upvotes: 1

mvikhona
mvikhona

Reputation: 101

I was also in your situation a bit time ago.

1 .Try using the same tag name in both lines : As in your case

<%@ Register TagPrefix="uc1" TagName="ContactForm" Src="~/Controls/VFEmailForm.ascx"  %>
<uc1:ContactForm ID="VFEmailForm" runat="server" />
  1. If it helps then ok, otherwise after making this change , try restarting the visual studio. This procedure helped me out.

Upvotes: 0

Related Questions