10

This question has been asked a few dozen times before; but has never been solved.

i have an UpdatePanel

<asp:UpdatePanel ID="UpdatePanelSetupToolbar" runat="server">
   <ContentTemplate>
      ...           
   </ContentTemplate>
</asp:UpdatePanel>      

But the visual page designer in Visual Studio (2010 (Professional (Windows (7 (Professional (64-bit)))))) gives the error:

Error Creating Control - UpdatePanelSetupToolbar

Type 'System.Web.UI.UserControl' does not have a public property named 'ContentTemplate'.

enter image description here
Edit: pretty colors in pretty screenshots are added for pretty effect

Now, strictly speaking, that is true: UserControl does not have a public property called ContentTemplate.

Fortunately my UpdatePanel is an UpdatePanel, and it does have a public property named 'ContentTemplate'.

So how do i convince Visual Studio that my UpdatePanel is an UpdatePanel?

Important additional notes

The code above doesn't actually fail as is:

<asp:UpdatePanel ID="UpdatePanelSetupToolbar" runat="server">
   <ContentTemplate>
      ...           
   </ContentTemplate>
</asp:UpdatePanel>  

It only fails when i have content inside the ... ContentTemplate:

    <asp:UpdatePanel ID="UpdatePanelSetupToolbar" runat="server">
        <ContentTemplate>
            <Vista:Toolbar ID="ToolbarSetup" runat="server">
                <ContentTemplate>
                    <asp:LinkButton ID="bbSetupDays" ToolTip="Specify how many allocations will be available on these selected days"
                    OnClick="bbSetupDays_Click"                                        
                    runat="server">Setup Selected Days</asp:LinkButton>         
                </ContentTemplate>
            </Vista:Toolbar>        
        </ContentTemplate>
    </asp:UpdatePanel>      
  • but Visual Studio is not complaining about inner ToolbarSetup
  • it's complaining about the outer UpdatePanelSetupToolbar control

So what's the deal with

Type '%s' does not have a public property named '%s'.

?

Unimportant additional notes

The ASP.net web-site compiles, builds, and runs fine. It's just the Visual Studio (2010) designer that complains.

So what's the deal with Type '%s' does not have a public property named '%s'.?

Series

This question is one in the ongoing Stackoverflow series, "Templating user controls":

Community
  • 1
  • 1
Ian Boyd
  • 246,734
  • 253
  • 869
  • 1,219
  • 1
    Have you ever taken a look at the temporary/intermediate files ASP.NET generates to see if there's anything unusual about the code that's built which might be causing the designer issues? – David W Oct 30 '13 at 17:50
  • I can't reproduce in Visual Studio 2012. Most controls that support data binding were updated to allow for strong typing. I believe a side-effect of that enhancement made this problem go away. http://www.asp.net/aspnet/overview/aspnet-and-visual-studio-2012/whats-new – Jamey Nov 04 '13 at 22:08
  • @KellyS.French i'll leave it to you to figure out which solution works. The bug is so aggravating i can't stand to look at it anymore. i'd kill for a fix, though. – Ian Boyd Nov 06 '13 at 16:50

2 Answers2

1

The update panel is really cool but you really can't make user controls with it. The good news is you can make asp.net user controls that have a javascript payload by following the same design pattern used to make the updatepanel for the ajaxcontroltoolkit.

I built this back in Mar 2009 because I needed a message box that didn't block the ui. I followed the design pattern for usercontrols using the ajaxcontroltoolkit. It has complete source and the VS intelisense works on the javascript. It's a usercontrol that you just drop on the page and it carries it's own javascript payload that you can ajaxify to your hearts content. It even works in a data repeater with no modifications. It was actually accepted as a ajaxcontroltoolkit usercontrol on the website asp.net.

It's free you could put it on github or other repository if you wanted.

http://gosylvester.com/downloads/messagebox.aspx

http://gosylvester.com/blog.aspx?id=55

danny117
  • 5,581
  • 1
  • 26
  • 35
0

You should solve this per design.

Put your update panel on a page and make the user control without an update panel.

reason: the update panel is intended to autogenerate clientside scripting for asyncronous postback as you surely know. The user control is a building block with a self contained functionality encapsulating complexity which should be placeable anywhere without requirements to the context and in this case at least you would need a scriptmanager on the page which instantiates the control.

T. Nielsen
  • 835
  • 5
  • 18
  • What if you had a control with no UI, in my case I have a control that will exclude the contained content from being searched and really has no visible component. It also doesn't use JavaScript. In any case, I still get the same error when I try to enclose an out-of-the-box control within my custom control. – Kelly S. French Nov 05 '13 at 16:19