Problem In Supporting Absolute Positioning

Last post 07-20-2004 12:36 PM by PLBlum. 1 replies.

Sort Posts:

  • Problem In Supporting Absolute Positioning

    07-19-2004, 1:58 PM
    I'm trying to build a user custom control (.ascx)
    I want to support absolute positioning in grid layout
    I'm using a grid panel (div - htmlgenericcontrol) and define a STYLE Property , but when I run the project , I get an "Object reference not set to an instance of an object."
    Here's my code , what's wrong?
    (I'm Using .Net FrameWork 1.1 & VS.Net 2003)


    Protected WithEvents pnlGrid1 As System.Web.UI.HtmlControls.HtmlGenericControl
    .
    .
    .
    Public Property Style() As String
    Get
    Return pnlGrid1.Attributes.Item("style")
    End Get
    Set(ByVal Value As String)
    pnlGrid1.Attributes.Item("style") = Value
    End Set
    End Property


    And here's the HTML code


    <DIV id="pnlGrid1" style="Z-INDEX: 101; POSITION: absolute" ms_positioning="GridLayout">
    .
    .
    .
    </DIV>


    ThnX
  • Re: Problem In Supporting Absolute Positioning

    07-20-2004, 12:36 PM
    • All-Star
      30,305 point All-Star
    • PLBlum
    • Member since 06-28-2002, 9:20 AM
    • Boston, MA
    • Posts 5,343
    • TrustedFriends-MVPs
    HtmlGenericControl exposes styles through its own Style property.

    Here's what I would do:
    Public ReadOnly Property Style As CssStyleCollection
    
    Get
    Return pnlGrid1.Style
    End Get
    End Property


    You will then be able to access this new property like this:

    UserControl1.Style.Add("name", "value")
    if (Not UserControl1.Style("name") Is Nothing) Then
    ' do something
    --- Peter Blum
    Creator of Peter's Data Entry Suite (formerly Professional Validation And More and Peter's Date Package) and Peter's Polling Package
    www.PeterBlum.com
Page 1 of 1 (2 items)
Microsoft Communities