Use user control in Web parts

Source: Internet
Author: User
Tags reflector
Recently, Web parts are often written in the project development process. However, Web Part development and debugging are not that convenient, so I thought that I could not use user control to develop my own modules, then add the user control to the Web part? This not only improves development efficiency, but also reuses previously developed modules. The following describes in detail how to perform the operation:
1. Create a new class library project and add a reference to system. Web.


2. Add a user control to the Project


3. Compile this Web Part

4. Add a strong name for the Assembly


5. Change the build output directory to c: \ Inetpub \ wwwroot \ WSS \ virtualdirectories \ [site port number] \ _ app_bin \

6. Modify assemblyinfo. CS and add using system. Security; and [Assembly: allowpartiallytrustedcallers ()]


7. Change the properties of user control and copy to output directory to copy If newer.


8. Build the project

9. Use reflector to open the generated DLL and find the assembly information.


10. Open the c: \ Inetpub \ wwwroot \ WSS \ virtualdirectories \ [site port number] \ WEB. config file and add a line under safecontrols.
<Safecontrol Assembly = "BR. webparts. ucontroldemo1, version = 1.0.0.0, culture = neutral, publickeytoken = 1e038d98fe593539 "namespace =" BR. webparts. ucontroldemo1 "typename =" usercontrolpart "Safe =" true "/>
The Assembly information is obtained from reflector.
10. Add the Web part to the webpage.

KaneboyArticleDeploy the feature of an ascx file to the station point set using delegatecontorl.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.