ASP. NET2.0 learning 8-webpart

Source: Internet
Author: User

WebPart Learning

Content:

Features

Five webpart Modes

Custom webpart

1. Introduction to Webpart Functions

1. Custom page content

2. Custom page layout

3. Import and export webpart

4. establish communication between different components

5. Management and personalized settings

2. Create a Webpart

1. Create a web Control

2. Custom webpart

Inherited from WebPart class

Important methods:

Public override void RenderControl (HtmlTextWriter writer)

Iii. WebPart mode:

WebPartManager1.DisplayMode = WebPartManager. BrowseDisplayMode;

WebPartManager1.DisplayMode = WebPartManager. DesignDisplayMode;

WebPartManager1.DisplayMode = WebPartManager. EditDisplayMode;

WebPartManager1.DisplayMode = WebPartManager. CatalogDisplayMode;

WebPartManager1.DisplayMode = WebPartManager. ConnectDisplayMode;

For the last four modes, you must use the following web. config to enable the personalized configuration.

<WebParts enableExport = "true">

<Personalization>

<Authorization>

<Allow users = "Gong" verbs = "entersharedscope"/>

</Authorization>

</Personalization>

</Webparts>

1. browsing mode:

Display parts. Other operations are not allowed.

2. Design Mode

Can be deleted, Drag and Drop parts

3. editing mode

Can be deleted, Drag and Drop parts

Modify the appearance, behavior, and attributes of a webpart.

4. Directory Mode

Supports the import and export functions and adds webpart controls.

You can export a webpart in directory mode.

1. Set web. config

<Webparts enableexport = "true">

<Personalization>

<Authorization>

<Allow users = "Gong" verbs = "entersharedscope"/>

</Authorization>

</Personalization>

</Webparts>

2. Set the exportmode attribute of the webpart control to non-none.

 

5. Connection Mode

Data communication between multiple webparts

Webpart connection:

1. Set communication interfaces between two webparts

Public interface itestword

{

String testtext

{

Get;

Set;

}

}

2. Implement the provider webpart

Public class TempWebpart: WebPart, ITestWord

[Personalizable (true), WebBrowsable (true)]

Public string TestText // ItestWord interface Data Implementation

Mark provider functions

[ConnectionProvider ("TestWordProvider ","TestWordProvider")]

Public ITestWord ProvideTest ()

{

Return this;

}

3. Implement the subscriber webpart

Public class TestConsumer: WebPart

// Mark the subscriber Function

[ConnectionConsumer ("TestWordConsumer ","TestWordConsumer")]

Public void GetTest (ITestWord testWord)

 

4. interface settings

Static connection:

<Asp: WebPartManager ID = "WebPartManager1" runat = "server">

<StaticConnections>

<Asp: WebPartConnection ID = "tt1" ProviderID = "temp1" ConsumerID = "testconsumer1"

ProviderConnectionPointID ="TestWordProvider"ConsumerConnectionPointID ="TestWordConsumer"/>

</StaticConnections>

</Asp: WebPartManager>

Dynamic connection:

In<Asp: WebPartManager ID = "WebPartManager1" runat = "server">

</Asp: WebPartManager> NO content

The settings below are the same

<Asp: WebPartZone ID = "WebPartZone3" runat = "server">

<ZoneTemplate>

<Test: tempwebpart id = "temp1" runat = "server"/>

</ZoneTemplate>

</Asp: WebPartZone>

<Asp: WebPartZone ID = "WebPartZone4" runat = "server">

<ZoneTemplate>

<Test: testconsumer ID = "testconsumer1" runat = "server"/>

</ZoneTemplate>

</Asp: WebPartZone>

 

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.