ASP.NET注册WebControl以在ASPX页面中使用

时间:2014-10-23 07:38:53

标签: asp.net .net vb.net webforms web-controls

我使用以下链接为视频流创建了一个WebControl VideoStreaming

Video Streaming with ASPNET SignalR and Html5

VideoStreaming.vb

<Assembly: OwinStartup(GetType(VideoStreaming))> 

Namespace Lantern.Demo.Client.CustomControl

    Public Class VideoStreaming
        Inherits WebControl

    '.... All code here

    End Class

End Namespace

编写完所有代码后,我在 Web.config 文件中声明/添加/注册了此控件:

<pages>
  <controls>
    <add assembly="VideoStreaming" tagPrefix="Web" namespace="Lantern.Demo.Client.CustomControl"/>
  </controls>
</pages>

但我无法将其作为常规控件添加到ASPX页面中。这就是我想要的:

<web:VideoStreaming runat="server" ID="video" ClientIDMode="Static" Width="300px" Height="300px" 
            Interval="100" Source="True" ScalingMode="TargetSize" StreamingMode="Target" TargetClientID="received" OnStreamed="onStreamed" 
            Style="border: solid 1px black" />

这突出显示以下错误:

Element 'VideoStreaming' is not a known element. This can occur if there is a compilation error in Website, or the Web.config file is missing.

enter image description here

我还尝试使用&lt;%Register%&gt; 目录注册控件。

<%@ Register Namespace="Lantern.Demo.Client.CustomControl" TagPrefix="Web" Assembly="VideoStreaming"%>

但这也行不通。我缺少什么或我必须做什么?

我见过以下链接:

  1. How to register User Control and Custom Control
  2. Registering Custom Controls Fail
  3. 如果需要更多信息,请与我们联系。感谢

    编辑:只是为了让您知道这不是 .ascx 控件。它是 WebControl ,它没有UI。

    我正在使用Visual Studio 2012。

0 个答案:

没有答案