Solved

Why am I getting errors viewing my ASP.Net user controls in the Visual Studio Designer?

Posted on 2014-10-16
5
640 Views
Last Modified: 2014-10-29
Hi:

I'm working with ASP.Net in Visual Studio 2010.
I've created several user controls which I include in .aspx pages.
They work fine at runtime, however I run into issues when I am in
"Design" view in Visual Studio.

I've added the following to my web.config:

    <pages>
      <controls>
        <add tagPrefix="ajaxToolkit" assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" />
        <add src="~/UserControls/UserControl1.ascx" namespace="" tagName="QuantityManagerUserControl" tagPrefix="ucUserControl1" />
        <add src="~/UserControls/UserControl2.ascx"  namespace="" tagName="PopupUserControl" tagPrefix="ucUserControl2" />
      </controls>
    </pages>

Open in new window


The user controls are included directly as part of the current solution.
I do not have name spaces defined for the controls.

Things are fine when I am in "Source View" of the designer.
But, when I go into design view. The controls do not render.
I get the following error message:
Error Rendering Control - UserControl1
An unhandled exception has occurred.
The 'namespace' attribute cannot be an empty string.

Open in new window


I've tried adding namespaces to the controls, removing the namespace tag from the web.config file.
I still get the same errors.

What am I missing here?
What do I need to do additionally in order to view the controls in the Visual Studio designer?

Thanks,
JohnB
0
Comment
Question by:jxbma
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 40391737
Try adding namespace in lines
<add src="~/UserControls/UserControl1.ascx" namespace="" tagName="QuantityManagerUserControl" tagPrefix="ucUserControl1" />

and use the project name as the namespace.
0
 
LVL 1

Author Comment

by:jxbma
ID: 40396125
::>CodeCruiser:

I try adding the project as my namespace in the web config.
Doing so caused additional errors when I looked at page in design view.

It should be noted that I don't have an explicit namespace in my user controls.
I tried adding a namespace there and then referencing that namespace in the web.config and I got the
same errors in design view mentioned above.

Is it possible to provide/point me to a sample that actually works.

Thanks,
JB
0
 
LVL 1

Accepted Solution

by:
jxbma earned 0 total points
ID: 40402935
OK. I finally figured this out.

If you have any user control definitions in the <pages><controls> section in your web config which contain a
namespace="" attribute, then it seems that Visual Studio (2010) will choke on displaying any of the
user controls defined in that section in the designer.

All you need is to have 1 entry in order for this to occur. It doesn't matter that the definition of the embedded control
that you are trying to view does not contain the 'namespace=""' attribute.

JB
0
 
LVL 1

Author Closing Comment

by:jxbma
ID: 40410201
Nobody responded to answering this. I was able to figure it out on my own.
0

Featured Post

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Read top line from CSV file 14 59
Wordpress contact form sending spam 2 53
wordpress 4.7.4, theme 8 43
VB.NET Parsing UDP Bytes 15 37
Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question