How does this code step

Discussion in 'ASP .Net' started by rn5a@rediffmail.com, Nov 5, 2006.

  1. Guest

    A custom server control containing a Button inherits from the
    WebControl class. I want to give users the option to change the
    BackColor of the Button. If this is the code in the ASPX page that uses
    the custom server control (whose class name is 'MyCls') which has been
    compiled into 'MyDLL.dll' using VBC

    <%@ Register Assembly="MyDLL" Namespace="MyNS" TagPrefix="cc1" %>
    <form runat="server">
    <cc1:MyCls ID="cccls" BackColor="red" runat="server"/>
    </form>

    then this does not change the BackColor of the Button control. To
    change the BackColor of the Button, the BackColor property of the
    Button control has to be overridden like this:

    Namespace MyNS
    Public Class MyCls : Inherits WebControl
    Private strBackColor As System.Drawing.Color

    Public Overrides Property BackColor() As System.Drawing.Color
    Get
    BackColor = strBackColor
    End Get
    Set(ByVal value As System.Drawing.Color)
    strBackColor = value
    End Set
    End Property

    Protected Overrides Sub CreateChildControls()
    MyBase.CreateChildControls()
    Dim btn1 As Button

    btn1 = New Button
    btn1.ID = "btn1"
    btn1.BackColor = strBackColor
    Me.Controls.Add(btn1)

    ChildControlsCreated = True
    End Sub
    End Class
    End Namespace

    The ASPX code shown at the beginning will now change the BackColor of
    the Button to red.

    What I would like to know is when the compiler encounters
    BackColor="red" in the ASPX code, how does the code flow after that? In
    other words, which line first gets executed in the VB class file &
    subsequently how does the code step from one line to the other in the
    VB class file?

    I don't have Visual Web Developer 2005 installed in my m/c which is why
    I am asking this question.
    , Nov 5, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. jaap de verwant slachter
    Replies:
    0
    Views:
    1,262
    jaap de verwant slachter
    Jul 1, 2003
  2. Roy in

    need step by step example

    Roy in, Aug 3, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    356
    Roy in
    Aug 3, 2003
  3. Steve Richter

    a step by step page

    Steve Richter, May 3, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    378
    Steve Richter
    May 3, 2005
  4. craig dicker
    Replies:
    1
    Views:
    366
    Peter Rilling
    Jul 10, 2005
  5. Claudio Grondi
    Replies:
    2
    Views:
    356
    Claudio Grondi
    Jul 3, 2006
Loading...

Share This Page