Asp.net| collection You may have used the DropDownList control in ASP.net, which has a collection property for the items that you use to set the Drop-down options for the combo box. This thoughtful approach makes the user feel more comfortable, and now we are also playing with our talents to create a property of the same function.
The control we're about to create is called WebPanel, which is used for Web site navigation and can shrink to look like this:
The first figure is the effect of the contraction, the second is the effect of contraction, although not flashy, but enough to explain the problem.
Next look at a picture:
This is the editor of the collection attribute, and today we're going to start talking about this effect.
In the editor of the collection property above, the main part is divided into two parts, the left part is the object's collection, the right part is the selected object's property, we can set the assignment to each property.
First, we define a class: Stringitem, which has two custom attributes: text for display, hypertext is a navigation hyperlink.
Using System;
Using System.Web.UI;
Namespace Nswebpanel
{
<summary>
Summary description of the Stringitem.
</summary>
///
public class StringItem:System.Web.UI.Control, IStateManager
{
private string _text;
private string _hypertext;
Public Stringitem ()
{
//
TODO: Add constructor logic here
//
}
public string Text
{
Set
{
_text = value;
}
Get
{
return _text;
}
}
public string Hypertext
{
Set
{
_hypertext = value;
}
Get
{
return _hypertext;
}
}
#region IStateManager Members
void Istatemanager.trackviewstate ()
{
Base. TrackViewState ();
}
BOOL Istatemanager.istrackingviewstate
{
Get
{
Return base. isTrackingViewState;
}
}
Object Istatemanager.saveviewstate ()
{
Return base. SaveViewState ();
}
void Istatemanager.loadviewstate (object state)
{
Base. LoadViewState (state);
}
#endregion
}
}
Then, you create a class that holds multiple Stringitem objects: Stringitems, you need to be aware that the class inherits collectionbase so that you can use the default collection property editor.
Using System;
Using System.Collections;
Using System.Web.UI;
Namespace Nswebpanel
{
<summary>
Summary description of the Stringitems.
</summary>
public class Stringitems:collectionbase, IStateManager
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.