asp.net – 自定义控件变为通用的“UserControl”,而不是其在Des
发布时间:2020-12-15 18:58:49 所属栏目: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 controls-- 并在代码背后: Name
我在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 – PipeLine模式和池标识是否会影响使用Integrated
- asp.net-mvc – 从ASP.NET MVC中采用“aspnet_ …”sql表
- asp.net-mvc-3 – 在MVC3中使用Html.LabelFor的表单标签中的
- asp.net – 在asp:Button中包装文本
- asp.net-mvc – ViewModel有自己的逻辑吗?
- 在VS环境下使用SVN
- ASP.NET C#在SQL Server数据库表中搜索
- asp.net – 什么原因“内部连接致命错误”
- asp.net – IIS Express(WebMatrix)打开外部连接
- asp.net-mvc-3 – MVC 3 json请求应该在异常时接收json响应
推荐文章
站长推荐
- asp.net“记住我”的cookie
- 如何将纯文本发布到ASP.NET Web API端点?
- asp.net – 如何从hotmail,live,gmail,yahoo导入
- .NET牛人应该知道些什么,我的回答
- 如何在asp.net C#代码后面的菜单控件中禁用特定菜
- 在asp.net中HttpContext.Current.User和Thread.C
- 通过asp.net 4.0中的“EnableViewState”和“Vie
- asp.net – Visual Studio 2012 – 哪里有ASPX设
- asp.net – Visual Studio和C#的竞争对手
- asp.net core webapi 服务端配置跨域的实例
热点阅读