ASP. NET compound control development

Source: Internet
Author: User
Using system;
Using system. Collections. Generic;
Using system. componentmodel;
Using system. LINQ;
Using system. text;
Using system. Web;
Using system. Web. UI;
Using system. Web. UI. webcontrols;

Namespace servercontrol1
{
[Defaultproperty ("text")]
[Toolboxdata ("<{0}: servercontrol1 runat = Server> </{0}: servercontrol1>")]
Public class servercontrol1: compositecontrol, inamingcontainer
{
[Bindable (true)]
[Category ("appearance")]
[Defaultvalue ("")]
[Localizable (true)]
Public String text
{
Get
{
String S = (string) viewstate ["text"];
Return (S = NULL )? "[" + This. ID + "]": S );
}

Set
{
Viewstate ["text"] = value;
}
}

Public String tip
{
Get {return viewstate ["AA"]. tostring ();}
Set {viewstate ["AA"] = value ;}
}
Textbox tb1;
Button BTN;
Label Lb;
Protected override void createchildcontrols ()
{
Controls. Add (New literalcontrol ("Tb1 = new Textbox ();
Tb1.text = "0 ";
Controls. Add (tb1 );
BTN = new button ();
BTN. Text = "login ";
BTN. commandname = "login ";
// BTN. Click + = new eventhandler (btn_click );
Controls. Add (BTN );
Lb = new label ();
LB. Text = "aaaaaaaaa ";
Controls. Add (LB );
}
// Triggered when you click an event of the Child control in the composite control. The event bubbles.

Protected override bool onbubbleevent (Object source, eventargs E)

{
Bool handed = false;
If (E is commandeventargs)
{
Commandeventargs Ce = (commandeventargs) E;
If (Ce. commandname = "login ")
{
LB. Text = "aaaaaaaa ";
Handed = true;
}
}
Return handed;
}

Public class checkeventargs: eventargs
{
Private bool match = false;

Public checkeventargs (INT difference)
{
If (difference = 0)
{
Match = true;
}
}
Public bool match
{
Get
{
Return match;
}
}
}
Public event checkeventhandler check;
Public Delegate void checkeventhandler (Object sender, checkeventargs CE );
}
}

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.