基于Asp.Net的控件开发涉及到两种,一种是用户控件,即通过vs自带的服务器控件进行组合以开发需求,该类控件的开发相对简单;另一种是自定义控件,开发难度较高。
1、在vs中新建一个类库的项目WebControl,添加对System.Web.UI程序集的引用,
2、在项目的AssemblyInfo.cs文件中添加“using System.Web.UI”等代码,代码如下所示:
using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Web.UI; //自行添加 // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("WebControl")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("WebControl")] [assembly: AssemblyCopyright("Copyright © 2016")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("33d4f2ba-7cf9-49a7-9b86-442e3beba5e9")] // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] /*自行添加*/ [assembly: WebResource("WebControl.resource.css.webctl.css", "text/css", PerformSubstitution = true)] [assembly: WebResource("WebControl.resource.js.webctl.js", "application/x-javascript", PerformSubstitution = true)] [assembly: WebResource("WebControl.resource.js.webctl.png", "image/png")]
2、添加一个类文件customcontrol.cs,编写如下代码:
标签:控件,WebControl,assembly,自定义,System,using,Net From: https://www.cnblogs.com/yuzhihui/p/5356314.html