Results 1 to 7 of 7

Thread: [RESOLVED] [2005] Express How do I implement Top and Left in a user control

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2005
    Location
    The Potteries (whats left)
    Posts
    6

    Resolved [RESOLVED] [2005] Express How do I implement Top and Left in a user control

    Total newbie at dot net dabbler at VB6 attempting to get to grips with VWD express.
    I have designed a user control (basically a table containing 24 buttons in cells)
    When I use this control I need to be able to set the Top and Left properties of the table from the calling page.

    To get the value into the usercontrol I think I should use (Top only - Left would be the same):-

    VB Code:
    1. Public Property ControlTop() As Integer
    2.         Get
    3.             Return iControlTop
    4.         End Get
    5.         Set(ByVal value As Integer)
    6.             iControlTop = value
    7.         End Set
    8.     End Property
    and then use ControlTop variable within the style section of the table definition :-

    HTML Code:
    <table style="z-index: 100; width: 600px; height: 45px">        
    <tr>
                <td style="width: 4%" >
                    <asp:Button ID="Button1" runat="server" Style="z-index: 100" Text="01" OnClick="HButton_Click" />
                </td>
                <td style="width: 4%"> 
                    <asp:Button ID="Button2" runat="server" Style="z-index: 100" Text="02" OnClick="HButton_Click" />
    could someone please point out the obvious and tell me how it should be done.
    The above 'exposes' ControlTop' but I would much prefer to expose 'Top' correctly but this gives me problems as well, a solution for both would be excelent.
    I have tried many things but cannot get anything to work - probably my total lack of HTML knowledge
    Thanks in advance

  2. #2

    Thread Starter
    New Member
    Join Date
    Mar 2005
    Location
    The Potteries (whats left)
    Posts
    6

    Re: [2005] Express How do I implement Top and Left in a user control

    OK, investigating somthing else and I've now got
    HTML Code:
    <table style="z-index: 100; width: 600px; height: 45px top: <%= iTop %>px left <%=iLeft %>px" >
    and
    VB Code:
    1. Microsoft.VisualBasic.Left
    to qualify the left that was giving the other problem but now the problem of attempting to use
    HTML Code:
    <uc1:HourControl ID="Hours1" runat="server" style="top: 10px left: 10px"/>
    Gives me the error
    Validation (ASP.Net): Attribute 'style' is not a valid attribute of element 'HourControl'.

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [2005] Express How do I implement Top and Left in a user control

    In your codebehind,
    Code:
    this.Hourse1.Attributes.Add("style","left:" + this.MyLeftProperty + ";top:" + this.MyTopProperty);

  4. #4

    Thread Starter
    New Member
    Join Date
    Mar 2005
    Location
    The Potteries (whats left)
    Posts
    6

    Re: [2005] Express How do I implement Top and Left in a user control

    Thanks for this but unfortunatly it doesn't mean a lot to me. The ; would indicate java or c (from conversation arround my desk) but as the script I am using is VB sorry now Im lost.
    Where does the (VB equivelent) above line go ? I assume into the codebehind for the usercontrol (to 'add' the 'style' and its attributes).
    I do not comprehend the use if 'this' - is it the name of the usercontrol ? but how is this declared?
    Sorry to ask for further help distinctly biased towards the group of 'idiot user grade' in which I am firmly entrenched :-(

  5. #5
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [2005] Express How do I implement Top and Left in a user control

    Not very different in VB.NET.

    In C#, you use 'this', in VB.NET, you say Me. this/Me refers to the current instance of the class. So:

    VB Code:
    1. Me.Hourse1.Attributes.Add("style","left:" + this.MyLeftProperty + ";top:" + this.MyTopProperty)

  6. #6

    Thread Starter
    New Member
    Join Date
    Mar 2005
    Location
    The Potteries (whats left)
    Posts
    6

    Re: [2005] Express How do I implement Top and Left in a user control [Resolved]

    Thanks

  7. #7
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [RESOLVED] [2005] Express How do I implement Top and Left in a user control

    Welcome.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width