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>