Wednesday 15 September 2010

asp.net - Class Inheritance from ASCX control -


I have a problem on the inheriting class that is attached to the ASX markup page I see, I wrote the following ASX markup and codebind Was:

ASCX

  & lt;% @ control language = "vb" AutoEventWireup = "false" codebahind = "headerblock.cssacks VB "Inheritance =" Central Web. AMP.U.Headerblock "%" & Lt; H1 & gt; & Lt; Abbr & gt; & Lt;% = me Label & gt; & Lt; / Abbr & gt; & Lt; Period & gt; & Lt; Asp: button id = "saveandreturnbutton" text = "salver e volter ..." runat = "server" cssClass = "saveandback" /> & Lt; Asp: button id = "savebutton" text = "salwar ..." runat = "server" cssClass = "save" /> & Lt; ASP: Button ID = "Return_Rates" text = "Voter ..." runat = "server" CssClass = "back" /> & Lt; / Span & gt; & Lt; / H1>  

codebehind

  Namespace EMP.UI Public Class HeaderBlock inherits System.Web.UI.WebControls.UserControl protected savedandreturnbutton Globalized .system.Web.UI.WebControls.Button protected protectedbutton protected as Global.System.Web.UI.WebControls.Button returned_results Global.System.Web.UI.WebControls.Button Public Overridable Sub TakeAction (ByVal eventID integer As the form of 'nothing', this base class end sub personal sub saveandreturn_Click (ByVal), as the object, byVal E. Global.System.EventArgs handles saveandreturnbutton.Click Me.TakeAction (3) End Sub Personal Sub savebutton_Click (ByVal is the form of this object, in the form of ByVal E. Global.System.EventArgs) Handle savebutton.Click Me.TakeAction (2) End Sub personal sub-return_results_Click (ByVal As this object, ByVal e Global.System.EventArgs Handle return_results.Click me.TechAction (1) and sub-end class and namespace  

Then, my intention is to use this base class (which has a markup), And get it in a non-mark-up class, and look at one page like this:

  Namespace EMP.UI Public Class FrontHeade R inherited EMP.UI.HeaderBlock Public Override Sub TakeAction (Integer as ByVal I) 'Child Trial Just Ended Up Ending Class End Namespace  

What's wrong with that examination?

EDITION

After speaking Little with Tim, I want to do something like this:

  & lt ;% @ Control language = "vb" AutoEventWireup = "false" codebehind = "HeaderBlock.ascx.vb" Inherits = "CentralWeb.EMP.UI.HeaderBlock"%> & Lt; H1 & gt; & Lt; Abbr & gt; & Lt;% = me Label & gt; & Lt; / Abbr & gt; & Lt; Period & gt; & Lt; Asp: button id = "saveandreturnbutton" text = "salver e volter ..." runat = "server" cssClass = "saveandback" /> & Lt; Asp: button id = "savebutton" text = "salwar ..." runat = "server" cssClass = "save" /> & Lt; ASP: Button ID = "Return_Rates" text = "Voter ..." runat = "server" CssClass = "back" /> & Lt; / Span & gt; & Lt; / H1> & Lt; Div class = "field" & gt; Control where this category relies on this category ... and & lt; / Div & gt; [Disclaimer: There was no  system for the original question. Web.UI.UserControl ]  

You must obtain from UserControl :

  Public Class Header Block Inherits System.Web.UI.UserControl ....  

But normally I do not inherit the class from UserControl because it is a frontend control in which There should not be too much business logic if you want to "extend" you can put it another UserControl in UserControl one or many other There can be control, hence a modular concept.


No comments:

Post a Comment