WSS Study Notes (2)-deploy "User Control" with quickpart to replace webpart

Source: Internet
Author: User

The manual webpart deployment method described in Note 1 is troublesome, and the visual interface cannot be seen during the development of webpart. it is inconvenient to set style attributes and debug them, this document uses the "user control" to replace webpart.

We also continued the previous example, which was implemented using "User Control" this time.

 

1. Create an ASP. NET web application in the solutionProgramName simpleascx

2. Create a "Web user control" page named ascxgrid. ascx

3. Drag a gridview and set properties.

Ascx page:

 
<% @ Control Language = "C #" autoeventwireup = "true" codebehind = "ascxgrid. ascx. CS "inherits =" simpleascx. ascxgrid "%> <asp: gridview id =" gridview1 "runat =" server ">  

CSCode:

Using system; using system. collections; using system. configuration; using system. data; using system. web; using system. web. security; using system. web. ui; using system. web. UI. htmlcontrols; using system. web. UI. webcontrols; using system. web. UI. webcontrols. webparts; namespace simpleascx {public partial class ascxgrid: system. web. UI. usercontrol {protected void page_load (Object sender, eventargs e) {datatable dt = getdatatable (); gridview1.datasource = DT; gridview1.databind ();} private datatable getdatatable () {datatable dt = new datatable (); DT. columns. add ("ID"); DT. columns. add ("name"); DT. columns. add ("date"); For (INT I = 0; I <20; I ++) {datarow DR = DT. newrow (); Dr [0] = I; Dr [1] = "colname1" + ":" + I; Dr [2] = "create Date:" + datetime. now; DT. rows. add (DR) ;}return DT ;}}}

4. regenerate,

Copy the simpleascx. dll file in the bin directory to the C: \ Inetpub \ wwwroot \ WSS \ virtualdirectories \ 80 \ bin directory.

Copy the ascxgrid. ascx file to the C: \ Inetpub \ wwwroot \ WSS \ virtualdirectories \ 80 \ wpresources directory.

 

OK. So far, the ascx user control has been created. Configure quickpart below

Same as deploying a webpart control:

1. Add quickpart. DLL to the C: \ Inetpub \ wwwroot \ WSS \ virtualdirectories \ 80 \ bin directory;

2. Set the Web. config of the website set, and add the following configuration section in configuration-> SharePoint-> safecontrols.

 
<Safecontrol Assembly = "quickpart, version = 1.0.0.0, culture = neutral, publickeytoken = 2d0bb71b2dd16f9e" namespace = "Microsoft. PRC. SharePoint" typename = "*" Safe = "true"/>

3. In configuration-> system. Web, find the trust configuration section to increase the trust level and change wss_minimal to full.

 

4. Import webpart

Go to the WSS site and choose website operations> website Settings> Web components"

Import Microsoft. PRC. Sharepoint. consumerquickpart and Microsoft. PRC. Sharepoint. providerquickpart to the Web Part Library.

 

5. Create a test page, quickparttest;

6. Add providerquickpart on the test page;

7. Edit the webpart. In the attribute bar on the right, you can view the created ascxgrid user control. After selecting the control, you can complete the selection.

 

Compared with the development and deployment of webpart, it is much more convenient and error-prone.

 

 

 

 

 

 

Vengen

2011-01-04

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.