In the ASP. NET development environment, we often use ready-made controls to drag them directly to the page for use. have you ever wondered whether we can develop self-used controls? This document uses vs2008 as the development tool and VB. NET as the development tool.ProgramDescribes how to create a server control project and test the Server Control in the development stage.
1. Create 「ASP. NETServer Control Project
First, execute the menu "archives \ add Project", select Visual Basic> Web from the project type, and select "ASP. NET Server Control template. In the Name text box, enter the project name, that is, the component file name. We enter bee. the web project name and component file are bee. web. DLL. Press the OK button to create a new ASP.. NET Server Control.
In the newly created "ASP. NET Server Control" project, a server control category (servercontrol1.vb) is added by default. This server control has event to help us add some control programs.Code. Currently, no modifications are made. You can directly use this control for testing.
Next, select project \ bee. web properties, set the root namespace of this component. Generally, the root namespace is the same as the component name, so that you can quickly find the relevant components when adding the reference.
Store the ASP. NET Server Control Project, specify the storage location, and press the Save button. The project-related files are stored in the project name folder.
2. Join the test website
Do not close the current "ASP.. NET Server Control Project, click File \ add \ new website, and select ASP.. Net website.
Add a reference to the test website and select the project tab. This tab lists other projects that can be added to the project. Select the bee. Web project and click OK.
First, perform the "build" action in the bee. Web project, and then switch to the page design of the test website. The servercontrol1 server control appears in the toolbox. This control can be directly dragged to the page for use. This control only render the text property value. You can change the text property value to "test text" in the control Property Window ", the control displays "test text ". Set the test website as a startup project. Press F5 to execute the program and you will see the results of the control in the execution phase.
Note: This article is also published in "the first it state help tie Ren Competition". If you think this articleArticleIt is helpful to you. Remember to add popularity when you connect to this article ^
Http://ithelp.ithome.com.tw/question/10011408