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

A

Ahmet Gunes

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
 
T

Teemu Keiski

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

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
 
A

Ahmet Gunes

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

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

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
 
A

Ahmet Gunes

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.

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

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

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,999
Messages
2,570,246
Members
46,842
Latest member
MableIwk73

Latest Threads

Top