asp.net – 自定义控件变为通用的“UserControl”,而不是其在Designer类中的实际类型
发布时间:2020-05-25 01:08:40 所属栏目:asp.Net 来源:互联网
导读:我在ASP.NET中有一个自定义控件(VB.NET代码),用ASCX定义: %@ Control Language=vb AutoEventWireup=false CodeBehind=MyControl.ascx.vb Inherits=Mynamespace.Controls.MyControl %!-- some html and other custom con
|
我在ASP.NET中有一个自定义控件(VB.NET代码),用ASCX定义: <%@ Control Language="vb" AutoEventWireup="false" CodeBehind="MyControl.ascx.vb" Inherits="Mynamespace.Controls.MyControl" %> <!-- some html and other custom controls--> 并在代码背后: Namespace Controls
Public Class MyControl
Inherits System.Web.UI.UserControl
这是在图书馆中设置的.不同的项目在页面中使用该控件: <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="mypage.aspx.vb"
Inherits="myproject.mypage" culture="auto" meta:resourcekey="Page" uiculture="auto"
Transaction="RequiresNew" MasterPageFile="Mynamespace.Master"
Theme="ThemeBase2" StylesheetTheme="ThemeBase2" %>
<%@ Register tagprefix="Controls" tagname="MyControl" src="../Controls/MyControl.ascx" %>
<%-- some asp.net --%>
<Controls:MyControl ID="mycontrol1" runat="server"
MyCustomProperty="value" />
但是,当我建立,我得到一个错误说
而在designer.vb页面中我看到: Protected WithEvents mycontrol1 As Global.System.Web.UI.UserControl 如何确保它成为: Protected WithEvents mycontrol1 As Global.Mynamespace.Controls.MyControl ? 解决方法您的ascx文件无法访问,因为它在库中您需要将ascx文件保存为库的嵌入式资源,并将其作为外部资源加载到Web应用程序中. 您可以咨询此link了解更多信息. 如果你想分享你的控件,我建议创建UserControl而不是CustomControl.不幸的是,有更多的工作,因为设计师是不可用的 (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net-mvc-3 – 任何好的样品开始使用Dapper?
- asp.net-mvc – 如何在jqueryui工具提示中显示jqueryui验证
- 如何在ASP.NET MVC控制器(ActionResult)中更改返回的Conten
- ASP.NET – 重定向301
- asp.net – 无法找到请求的.Net Framework数据提供程序.它可
- asp.net-mvc-3 – 为什么ValidationSummary(true)显示属性错
- asp.net – 来自WebHttpBinding的WCF服务中的Access Sessio
- asp.net-mvc-2 – 实体框架4 CTP 4/CTP 5通用存储库模式和单
- asp.net – 联合身份验证和“加密操作期间发生错误”
- ASP.NET会员密码到期
