UserControl没有名为ContentTemplate的公共属性

编程入门 行业动态 更新时间:2024-10-20 01:33:31
本文介绍了UserControl没有名为ContentTemplate的公共属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

这个问题已经问了几十遍了;但从未解决.

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

我有一个 UpdatePanel

i have an UpdatePanel

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

但是Visual Studio(2010(Professional(Windows(7(Professional(64-bit))))))中的 visual page designer 出现错误:

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

创建控件时发生错误-UpdatePanelSetupToolbar

Error Creating Control - UpdatePanelSetupToolbar

类型'System.Web.UI.UserControl'没有名为'ContentTemplate'的公共属性.

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

在漂亮的屏幕截图中添加漂亮的颜色以达到漂亮的效果

现在,严格来讲,这是真的: 没有没有名为ContentTemplate的公共属性.

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

幸运的是,我的UpdatePanel是 UpdatePanel ,并且确实具有名为 'ContentTemplate' .

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

那么我如何说服Visual Studio我的UpdatePanel是UpdatePanel?

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

上面的代码实际上并没有按原样失败:

The code above doesn't actually fail as is:

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

仅当我在... ContentTemplate中包含内容时,它才会失败:

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>

  • 但是Visual Studio并不抱怨内部ToolbarSetup
  • 它在抱怨外部的UpdatePanelSetupToolbar控件
    • but Visual Studio is not complaining about inner ToolbarSetup
    • it's complaining about the outer UpdatePanelSetupToolbar control
    • 那怎么办

      类型'%s'没有名为'%s'的公共属性.

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

      ?

      ASP网站编译,构建和运行 fine .只是Visual Studio(2010)设计师在抱怨.

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

      那么Type '%s' does not have a public property named '%s'.怎么了?

      此问题是正在进行的Stackoverflow系列中的一个问题,模板化用户控件" :

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

      • 如何向用户控件添加模板?
      • 如何从Control(而不是UserControl)继承?
      • UserControl具有IsPostBack,但Control没有
      • UserControl没有名为ContentTemplate的公共属性
      • 如何从web.config中指定CodeFileBaseClass?
      • How to add a Templating to a UserControl?
      • How to inherit from Control, rather than UserControl?
      • UserControl has IsPostBack, but Control does not
      • UserControl does not have public property named ContentTemplate
      • How do i specify CodeFileBaseClass from web.config?
      推荐答案

      更新面板非常酷,但是您真的无法使用它来进行用户控制.好消息是,您可以按照用于制作ajaxcontroltoolkit的updatepanel的相同设计模式,来制作具有javascript负载的asp用户控件.

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

      我在2009年3月建立了这个程序,因为我需要一个不会阻止ui的消息框.我使用ajaxcontroltoolkit遵循了用户控件的设计模式.它具有完整的源代码,并且VS intelisense可以在javascript上运行.这是一个用户控件,您只需将其放到页面上即可,它带有自己的javascript有效负载,可以将其添加到您的内容中.它甚至可以在没有任何修改的数据转发器中工作.实际上,它在asp网站上被接受为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.

      它是免费的,如果需要,可以将其放在github或其他存储库上.

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

      gosylvester/downloads/messagebox.aspx

      gosylvester/blog.aspx?id=55

更多推荐

UserControl没有名为ContentTemplate的公共属性

本文发布于:2023-11-14 00:14:23,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1585691.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:属性   UserControl   ContentTemplate

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!