1: Base class SkinnedforumWebControl: WebControl, InamingContainer
1) Default constructor
Public SkinnedforumWebControl () {
// Attempt to get the current user
User = users.getloggedonuser ();
// is the user not availabe - Must be anonymous
IF (user == NULL)
Users.trackanonymoususers ();
// set the suitstyle for the page
IF (user! = null)
Skinname = User.skin;
Else
Skinname = globals.skin;
// if we have an instance of context, let's attempt to
// Get the forumid so we can save the user from Writing
// the code
IF (NULL! = context) {
GetPostIDFromRequest ();
GetforumidFromRequest ();
GetforumGroupIDFromRequest ();
GetReturnURLFROMREQUEST ();
}
}
2) 4 custom methods
// Retrieves the Postid, ForumID, Forum The Request QueryString / Post.
Private void getpostidFromRequest ()
Private void getforumidFromRequest ()
Private void forumgroupid ()
Private void getreturnURLFROMREQUEST ()
3) Rewriting method
Protected Override Void CreateChildControls () {
Control Skin;
// load the Skin (.ascx) as an Object Instance
Skin = loadingskin ();
// to be overrided, initialize the control template and populate the control with value
Initializeskin (Skin);
Controls.add (skin);
}
4) Attribute Accessor ...
2: Inherited class
1) Attribute
// Assign a Default Template Name
String SkinfileName = "Skin-login.ascx";
// Controls in (.ascx) Template
Textbox username;
Textbox password;
Button loginbutton;
Checkbox autological;
2) Constructor
Public login (): Base () {
// Assign a Default Template Name
IF (SKINFILENAME == NULL)
Skinfilename = SkinFileName;
}
3) Rewind 2 base types
Protected Override Void CreateChildControls () {
// if the user is already authenticated we have no work to do
IF (page.Request.isauthenticated) return;
Base.createchildControls ();
}
Override protected void initializeskin (Control Skin) {
// Find the login button
LoginButton = (Button) Skin.FindControl ("LoginButton");
LoginButton.Click = New System.EventHandler (LoginButton_Click);
// add more ......
}
4) Custom control method
Public void loginbutton_click (Object Sender, Eventargs E)