Persisting a property (e.g. TabIndex) in a control's Tag on creation

Discussion in 'ASP .Net Building Controls' started by Ahmet Gunes, Jun 10, 2004.

  1. Ahmet Gunes

    Ahmet Gunes Guest

    Hi Friends,

    I'm building a web control. I came to a point that I have to persist a property (especially TabIndex) in the control's tag when the control is dropped on a Web form.
    I tried several methods but none of them worked. Here is one of the methods I tried:

    <PersistenceMode(PersistenceMode.Attribute), DefaultValue(-1)> Public Overrides Property TabIndex() As Short
    Get
    Return MyBase.TabIndex
    End Get
    Set(ByVal Value As Short)
    MyBase.TabIndex = Value
    End Set
    End Property

    And either in the Constructor or Init methods I set TabIndex to "0".

    What I want is to get an HTML script as follows when I drop the control on a web form:

    <cc3:MyTextBoxHighlight id="MyTextBoxHighlight1" style="Z-INDEX: 102; LEFT: 336px; POSITION: absolute; TOP: 176px"
    runat="server" HighlightColor="192, 0, 0" TabIndex="0"></cc3:MyTextBoxHighlight>

    But unfortunately, the TabIndex="0" attribute is not shown until I manually change it in the Properties window.

    Can anyone help? Is what I try to do possible?

    Thanks in advance,

    AG
    Ahmet Gunes, Jun 10, 2004
    #1
    1. Advertising

  2. Ahmet Gunes

    Teemu Keiski Guest

    Hi,

    so you mean TabIndex="0" should be automatically on the control at web form when dragging the control from Toolbox?. In that case, you could mark the control with ToolBoxData attribute in which you specify the default markup. This way no property override is needed

    See:
    http://msdn.microsoft.com/library/d...systemwebuitoolboxdataattributeclasstopic.asp

    --
    Teemu Keiski
    MCP, Microsoft MVP (ASP.NET), AspInsiders member
    ASP.NET Forum Moderator, AspAlliance Columnist
    http://blogs.aspadvice.com/joteke

    "Ahmet Gunes" <> wrote in message news:...
    Hi Friends,

    I'm building a web control. I came to a point that I have to persist a property (especially TabIndex) in the control's tag when the control is dropped on a Web form.
    I tried several methods but none of them worked. Here is one of the methods I tried:

    <PersistenceMode(PersistenceMode.Attribute), DefaultValue(-1)> Public Overrides Property TabIndex() As Short
    Get
    Return MyBase.TabIndex
    End Get
    Set(ByVal Value As Short)
    MyBase.TabIndex = Value
    End Set
    End Property

    And either in the Constructor or Init methods I set TabIndex to "0".

    What I want is to get an HTML script as follows when I drop the control on a web form:

    <cc3:MyTextBoxHighlight id="MyTextBoxHighlight1" style="Z-INDEX: 102; LEFT: 336px; POSITION: absolute; TOP: 176px"
    runat="server" HighlightColor="192, 0, 0" TabIndex="0"></cc3:MyTextBoxHighlight>

    But unfortunately, the TabIndex="0" attribute is not shown until I manually change it in the Properties window.

    Can anyone help? Is what I try to do possible?

    Thanks in advance,

    AG
    Teemu Keiski, Jun 12, 2004
    #2
    1. Advertising

  3. Ahmet Gunes

    Ahmet Gunes Guest

    Hi Teemu,

    Ok. that worked. But what we exactly want to do is to set the tabIndex property to an arbitrary value (e.g. Page.Controls.Count) in the control's Init event so that the programmer will not have to set the tabIndex property of this control manually.

    Although when I drop the control on to a webform, the property seems to be already set (e.g. to "2") in the "Properties" window, the html code seems not to be in synch with the properties window. The code still shows tabIndex="0". When I change the property value in the Properties window, however, the change is successfully saved into the html code.

    In short:

    When I drop an instance of the control the first time I want tabIndex="1" in the html code
    When I drop another instance of the control, this second instance shoud have tabIndex="1" in the html code.

    Is that possible?

    Yours,

    AG

    "Teemu Keiski" <> wrote in message news:...
    Hi,

    so you mean TabIndex="0" should be automatically on the control at web form when dragging the control from Toolbox?. In that case, you could mark the control with ToolBoxData attribute in which you specify the default markup. This way no property override is needed

    See:
    http://msdn.microsoft.com/library/d...systemwebuitoolboxdataattributeclasstopic.asp

    --
    Teemu Keiski
    MCP, Microsoft MVP (ASP.NET), AspInsiders member
    ASP.NET Forum Moderator, AspAlliance Columnist
    http://blogs.aspadvice.com/joteke

    "Ahmet Gunes" <> wrote in message news:...
    Hi Friends,

    I'm building a web control. I came to a point that I have to persist a property (especially TabIndex) in the control's tag when the control is dropped on a Web form.
    I tried several methods but none of them worked. Here is one of the methods I tried:

    <PersistenceMode(PersistenceMode.Attribute), DefaultValue(-1)> Public Overrides Property TabIndex() As Short
    Get
    Return MyBase.TabIndex
    End Get
    Set(ByVal Value As Short)
    MyBase.TabIndex = Value
    End Set
    End Property

    And either in the Constructor or Init methods I set TabIndex to "0".

    What I want is to get an HTML script as follows when I drop the control on a web form:

    <cc3:MyTextBoxHighlight id="MyTextBoxHighlight1" style="Z-INDEX: 102; LEFT: 336px; POSITION: absolute; TOP: 176px"
    runat="server" HighlightColor="192, 0, 0" TabIndex="0"></cc3:MyTextBoxHighlight>

    But unfortunately, the TabIndex="0" attribute is not shown until I manually change it in the Properties window.

    Can anyone help? Is what I try to do possible?

    Thanks in advance,

    AG
    Ahmet Gunes, Jun 14, 2004
    #3
  4. Ahmet Gunes

    Ahmet Gunes Guest

    sorry,

    in the second sentence starting with "When.." value of tabIndex should be "2"...

    When I drop another instance of the control, this second instance shoud have tabIndex="2" in the html code.

    "Ahmet Gunes" <> wrote in message news:...
    Hi Teemu,

    Ok. that worked. But what we exactly want to do is to set the tabIndex property to an arbitrary value (e.g. Page.Controls.Count) in the control's Init event so that the programmer will not have to set the tabIndex property of this control manually.

    Although when I drop the control on to a webform, the property seems to be already set (e.g. to "2") in the "Properties" window, the html code seems not to be in synch with the properties window. The code still shows tabIndex="0". When I change the property value in the Properties window, however, the change is successfully saved into the html code.

    In short:

    When I drop an instance of the control the first time I want tabIndex="1" in the html code
    When I drop another instance of the control, this second instance shoud have tabIndex="1" in the html code.

    Is that possible?

    Yours,

    AG

    "Teemu Keiski" <> wrote in message news:...
    Hi,

    so you mean TabIndex="0" should be automatically on the control at web form when dragging the control from Toolbox?. In that case, you could mark the control with ToolBoxData attribute in which you specify the default markup. This way no property override is needed

    See:
    http://msdn.microsoft.com/library/d...systemwebuitoolboxdataattributeclasstopic.asp

    --
    Teemu Keiski
    MCP, Microsoft MVP (ASP.NET), AspInsiders member
    ASP.NET Forum Moderator, AspAlliance Columnist
    http://blogs.aspadvice.com/joteke

    "Ahmet Gunes" <> wrote in message news:...
    Hi Friends,

    I'm building a web control. I came to a point that I have to persist a property (especially TabIndex) in the control's tag when the control is dropped on a Web form.
    I tried several methods but none of them worked. Here is one of the methods I tried:

    <PersistenceMode(PersistenceMode.Attribute), DefaultValue(-1)> Public Overrides Property TabIndex() As Short
    Get
    Return MyBase.TabIndex
    End Get
    Set(ByVal Value As Short)
    MyBase.TabIndex = Value
    End Set
    End Property

    And either in the Constructor or Init methods I set TabIndex to "0".

    What I want is to get an HTML script as follows when I drop the control on a web form:

    <cc3:MyTextBoxHighlight id="MyTextBoxHighlight1" style="Z-INDEX: 102; LEFT: 336px; POSITION: absolute; TOP: 176px"
    runat="server" HighlightColor="192, 0, 0" TabIndex="0"></cc3:MyTextBoxHighlight>

    But unfortunately, the TabIndex="0" attribute is not shown until I manually change it in the Properties window.

    Can anyone help? Is what I try to do possible?

    Thanks in advance,

    AG
    Ahmet Gunes, Jun 14, 2004
    #4
    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. Mad Scientist Jr
    Replies:
    0
    Views:
    624
    Mad Scientist Jr
    Mar 22, 2006
  2. shruds
    Replies:
    1
    Views:
    746
    John C. Bollinger
    Jan 27, 2006
  3. injy
    Replies:
    0
    Views:
    219
  4. max

    Tabindex property

    max, Dec 11, 2003, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    85
  5. xb

    Persisting Custom Control's Child tag's values

    xb, May 21, 2004, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    138
Loading...

Share This Page