asp.net 2.0 use Web Part to create application bis (total two)

Source: Internet
Author: User
Asp.net|web| Program | create

1.Web Part Newsletter
Web parts can communicate with each other, providers publish interfaces, subscribers get data through interfaces, WebPartManager manage communications, obtain interfaces from providers, publish interfaces to subscribers, and communicate either statically or dynamically, connectionszone Provides late-bound UI
Communications provider
Implementation method return interface, method attribute [ConnectionProvider]
[ConnectionProvider ("Zip Code", "Zipcodeprovider")]
Public Izipcode Getzipcodeinterface ()
{
return this; Assumes control implements Izipcode
}

Izipcode.getzipcode implementation
public string Getzipcode ()
{
return _zip;
Newsletter subscribers
The implementation method receives the interface parameter, the method characteristic [ConnectionConsumer]
[ConnectionConsumer ("Zip Code", "Zipcodeconsumer")]
public void Getizipcodeinterface (Izipcode provider)
{
String zip = provider. Getzipcode (); Get zip code from provider

static mode of communication
Defined in the WebPartManager <StaticConnections> element, the end user cannot modify
Examples of <asp:Connection>
<asp:webpartmanager id= "WebPartManager1" runat= "Server" >
<StaticConnections>
<asp:connection id= "zipcodeconnection" runat= "Server"
Providerid= "Weather1" providerconnectionpointid= "Zipcodeprovider"
Consumerid= "News1" consumerconnectionpointid= "Zipcodeconsumer"/>
</StaticConnections>
</asp:webpartmanager>2.connectionszone Control
Provides the UI for the Web Part to communicate, end users, rather than developers creating communication relationships
<asp:connectionszone id= "ConnectionsZone1"
runat= "Server"/>3.web Parts personalization
Web Parts Personalized Service
Automatically saves the properties (layout, appearance, and so on) of the related Web Part to automatically save custom attributes marked as Personalizableattribute
The PersonalizationAdministration class provides personalized service api,provider-based for flexible data storage
Per-user personalization, [personalizable] saves custom attributes for each user, string _stocks; e.g., "MSFT,INTC,AMZN"
[WebBrowsable]
[Personalizable]
public string Stocks
{
get {return _stocks;}
set {_stocks = value;}
}

Shared Personalization
[Personalizable (personalizationscope.-shared)] persists properties on Shared basis
String _stocks; e.g., "MSFT,INTC,AMZN"

[WebBrowsable]
[Personalizable (personalizationscope.shared)]
public string Stocks
{
get {return _stocks;}
set {_stocks = value;}
}
Personalized service is based on provider mode
Using SQL Server Provider
<configuration>
<system.web>
<webParts>
<personalization defaultprovider= "Aspnetsqlpersonalizationprovider"/>
</webParts>
</system.web>
</configuration>4 Custom Web Parts
Adding Custom Actions
public class Mywebpart:webpart
{
public override WebPartVerbCollection Verbs
{
get {
EnsureChildControls ();
WebPartVerb verb =
New WebPartVerb (New Webparteventhandler (onclearresults));
Verb. Text = "Clear Results";
webpartverb[] verbs = new webpartverb[] {verb};
Return to New WebPartVerbCollection (base. Verbs, Verbs);
}
}

    void Onclearresults (object sender, WebPartEventArgs args) { }
 
}5. Export Web Part
Webpart.exportmode property, Webpartexportmode.none (default), Webpartexportmode.all
Webpartexportmode.nonsensitivedata,all "and" nonsensitivedata "add export operations so that Web Part can be exported
only [personalizable] properties, Personalizableattribute.issensitive recognizes the sensitive property
Export all Properties
public class Mywebpart:webpart
{
     public Mywebpart ()
    {
        exportmode = Webpartexportmode.all;
   }
 
} Export the selected properties public class Mywebpart:webpart
{
    public mywebpart ()
     {
        exportmode = webpartexportmode.nonsensitivedata;
   }

This property would be exported
[Personalizable (Personalizationscope.user, false)]
public string ZipCode
{  }

This one would not
[Personalizable (Personalizationscope.user, True)]
public string SocialSecurityNumber
{  }

}



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.